Files
threshold/internal/clientcache/internal/db/options_test.go
T
429247f407 [COMPLIANCE] Update Copyright Headers (#6282)
* [COMPLIANCE] Update Copyright and License Headers

* chore: make gen to generate files with copyright headers

* chore: update missed copyright headers

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Justin Nguyen <justin.nguyen@hashicorp.com>
2026-01-28 11:05:07 -06:00

57 lines
1.4 KiB
Go

// Copyright IBM Corp. 2020, 2025
// SPDX-License-Identifier: BUSL-1.1
package db
import (
"testing"
"github.com/hashicorp/go-dbw"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_GetOpts(t *testing.T) {
t.Parallel()
t.Run("default", func(t *testing.T) {
opts, err := getOpts()
require.NoError(t, err)
testOpts := options{
withDbType: dbw.Sqlite,
}
assert.Equal(t, opts, testOpts)
})
t.Run("WithUrl", func(t *testing.T) {
url := "something"
opts, err := getOpts(WithUrl(url))
require.NoError(t, err)
testOpts := getDefaultOptions()
testOpts.withUrl = url
assert.Equal(t, opts, testOpts)
})
t.Run("WithDebug", func(t *testing.T) {
opts, err := getOpts(WithDebug(true))
require.NoError(t, err)
testOpts := getDefaultOptions()
testOpts.withDebug = true
assert.Equal(t, opts, testOpts)
})
t.Run("withTestValidSchemaVersion", func(t *testing.T) {
version := "v1"
opts, err := getOpts(withTestValidSchemaVersion(version))
require.NoError(t, err)
testOpts := getDefaultOptions()
testOpts.withSchemaVersion = version
assert.Equal(t, opts, testOpts)
})
t.Run("WithForceResetSchema", func(t *testing.T) {
opts, err := getOpts(WithForceResetSchema(true))
require.NoError(t, err)
testOpts := getDefaultOptions()
assert.False(t, testOpts.withForceResetSchema)
testOpts.withForceResetSchema = true
assert.Equal(t, opts, testOpts)
})
}