* feature (db): add Db.UnderlyingDB() This is needed to allow for integration with bits that need a *dbw.DB * feature (kms): add new go-kms-wrapping/extras/kms dependency * refactor (kms): schema changes required to adopt extras/kms pkg * refactor (kms/iam): rename to DeprecateCreateKeysTx(...) * refactor (kms): remove deprecated test * refactor (kms): refactor Kms type This refactor includes renaming the existing type to DeprecatedKms and then refactoring the Kms type to become a wrapper of go-kms-wrapping/extras/kms * refactor (kms): delete all the unneeded bits All this stuff is not needed now that we're using go-kms-wrapping/extras/kms * refactor (db): fixup tests after kms refactor * refactor (kms/tests): use testing.TB for test helpers Our test helper packages were not possible to use with benchmarks. This refactor switches to testing.TB to allow both tests and benchmarks to use the helpers. * tests (session benchmarks): refactor to use new Kms type * refactor (schema): rm test which relies on deprecated Kms code * refactor (kms): post rebase on main changes required * chore (kms refactor): re-add unit test from main * refactor (kms): uses migrations that don't include KMS schema changes
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package kms
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/boundary/internal/db"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// Test_GetOpts provides unit tests for GetOpts and all the options
|
|
func Test_GetOpts(t *testing.T) {
|
|
t.Parallel()
|
|
t.Run("WithLimit", func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
// test default of 0
|
|
opts := getOpts()
|
|
testOpts := getDefaultOptions()
|
|
testOpts.withLimit = 0
|
|
assert.Equal(opts, testOpts)
|
|
|
|
opts = getOpts(WithLimit(-1))
|
|
testOpts = getDefaultOptions()
|
|
testOpts.withLimit = -1
|
|
assert.Equal(opts, testOpts)
|
|
|
|
opts = getOpts(WithLimit(1))
|
|
testOpts = getDefaultOptions()
|
|
testOpts.withLimit = 1
|
|
assert.Equal(opts, testOpts)
|
|
})
|
|
t.Run("WithOrderByVersion", func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
opts := getOpts(WithOrderByVersion(db.DescendingOrderBy))
|
|
testOpts := getDefaultOptions()
|
|
testOpts.withOrderByVersion = db.DescendingOrderBy
|
|
assert.Equal(opts, testOpts)
|
|
})
|
|
t.Run("WithKeyId", func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
opts := getOpts(WithKeyId("100"))
|
|
testOpts := getDefaultOptions()
|
|
testOpts.withKeyId = "100"
|
|
assert.Equal(opts, testOpts)
|
|
})
|
|
}
|