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/host/options_test.go

35 lines
890 B

package host
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_GetOpts(t *testing.T) {
t.Parallel()
t.Run("WithLimit", func(t *testing.T) {
opts, err := GetOpts(WithLimit(1))
require.NoError(t, err)
testOpts := getDefaultOptions()
testOpts.WithLimit = 1
assert.Equal(t, opts, testOpts)
})
t.Run("WithOrderByCreateTime-desc", func(t *testing.T) {
opts, err := GetOpts(WithOrderByCreateTime(false))
require.NoError(t, err)
testOpts := getDefaultOptions()
testOpts.WithOrderByCreateTime = true
assert.Equal(t, opts, testOpts)
})
t.Run("WithOrderByCreateTime-asc", func(t *testing.T) {
opts, err := GetOpts(WithOrderByCreateTime(true))
require.NoError(t, err)
testOpts := getDefaultOptions()
testOpts.WithOrderByCreateTime = true
testOpts.Ascending = true
assert.Equal(t, opts, testOpts)
})
}