...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package validate
16
17 import (
18 "testing"
19
20 "github.com/stretchr/testify/require"
21 )
22
23 func TestSchemaOptions(t *testing.T) {
24 t.Run("EnableObjectArrayTypeCheck", func(t *testing.T) {
25 opts := &SchemaValidatorOptions{}
26 setter := EnableObjectArrayTypeCheck(true)
27 setter(opts)
28 require.True(t, opts.EnableObjectArrayTypeCheck)
29 })
30
31 t.Run("skipSchemataResult", func(t *testing.T) {
32 opts := &SchemaValidatorOptions{}
33 setter := WithSkipSchemataResult(true)
34 setter(opts)
35 require.True(t, opts.skipSchemataResult)
36 })
37
38 t.Run("default Options()", func(t *testing.T) {
39 opts := &SchemaValidatorOptions{}
40 setters := opts.Options()
41
42 target := &SchemaValidatorOptions{}
43 for _, apply := range setters {
44 apply(target)
45 }
46 require.Equal(t, opts, target)
47 })
48
49 t.Run("all set Options()", func(t *testing.T) {
50 opts := &SchemaValidatorOptions{
51 EnableObjectArrayTypeCheck: true,
52 EnableArrayMustHaveItemsCheck: true,
53 recycleValidators: true,
54 recycleResult: true,
55 skipSchemataResult: true,
56 }
57 setters := opts.Options()
58
59 target := &SchemaValidatorOptions{}
60 for _, apply := range setters {
61 apply(target)
62 }
63 require.Equal(t, opts, target)
64 })
65 }
66
View as plain text