You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
boundary/internal/session/options_test.go

52 lines
1.3 KiB

package session
import (
"testing"
"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("WithScopeId", func(t *testing.T) {
assert := assert.New(t)
opts := getOpts(WithScopeId("o_1234"))
testOpts := getDefaultOptions()
testOpts.withScopeId = "o_1234"
assert.Equal(opts, testOpts)
})
t.Run("WithOrder", func(t *testing.T) {
assert := assert.New(t)
opts := getOpts(WithOrder("create_time asc"))
testOpts := getDefaultOptions()
testOpts.withOrder = "create_time asc"
assert.Equal(opts, testOpts)
})
t.Run("WithUserId", func(t *testing.T) {
assert := assert.New(t)
opts := getOpts(WithUserId("u_1234"))
testOpts := getDefaultOptions()
testOpts.withUserId = "u_1234"
assert.Equal(opts, testOpts)
})
}