Files
threshold/internal/host/options_test.go
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
961 B
Go
Raw Normal View History

2023-02-02 17:15:17 -08:00
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
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)
})
}