-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall_of_test.go
44 lines (35 loc) · 869 Bytes
/
all_of_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package jsonschema_test
import (
"testing"
"github.com/aacebo/jsonschema"
)
func TestAllOf(t *testing.T) {
RunAll("./testcases/all_of", jsonschema.New(), t)
t.Run("should succeed", func(t *testing.T) {
schema := jsonschema.Builder().
AllOf(
jsonschema.Builder().
Object().
Properties(map[string]jsonschema.Schema{
"test": jsonschema.Builder().String().Build(),
}).
AdditionalProperties(jsonschema.Builder().Integer().Build()).
Required("test").
Build(),
).Build()
errs := jsonschema.Compile(schema)
if len(errs) > 0 {
t.Error(errs)
}
errs = jsonschema.Validate(schema, struct {
Test string `json:"test"`
Other int `json:"other"`
}{"test", 1})
if len(errs) > 0 {
t.Error(errs)
}
})
}
func BenchmarkAllOf(b *testing.B) {
RunAllBench("./testcases/all_of", jsonschema.New(), b)
}