Co-authored-by: Todd Knight <T.Alan.Knight@gmail.com> Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com> Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>
31 lines
752 B
Go
31 lines
752 B
Go
package handlers
|
|
|
|
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("WithDiscardUnknownFields", func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
// test default of 0
|
|
opts := getOpts()
|
|
testOpts := getDefaultOptions()
|
|
testOpts.withDiscardUnknownFields = false
|
|
assert.Equal(opts, testOpts)
|
|
|
|
opts = getOpts(WithDiscardUnknownFields(true))
|
|
testOpts = getDefaultOptions()
|
|
testOpts.withDiscardUnknownFields = true
|
|
assert.Equal(opts, testOpts)
|
|
|
|
opts = getOpts(WithDiscardUnknownFields(false))
|
|
testOpts = getDefaultOptions()
|
|
testOpts.withDiscardUnknownFields = false
|
|
assert.Equal(opts, testOpts)
|
|
})
|
|
}
|