/
utils_test.go
62 lines (52 loc) · 1.32 KB
/
utils_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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package jschema_test
import (
"testing"
"github.com/NaturalSelectionLabs/jschema"
"github.com/ysmood/got"
)
func TestChangeDefs(t *testing.T) {
g := got.T(t)
type A struct {
ID int
}
type B struct {
A A
}
s := jschema.New("")
scm := s.Define(B{})
old := g.JSON(s.String())
g.Eq(g.JSON(g.ToJSON(s.ToStandAlone(scm))), map[string]interface{} /* len=2 */ {
"$defs": map[string]interface{} /* len=2 */ {
"A": map[string]interface{} /* len=6 */ {
`additionalProperties` /* len=20 */ : false,
"description": `github.com/NaturalSelectionLabs/jschema_test.A`, /* len=46 */
"properties": map[string]interface{}{
"ID": map[string]interface{}{
"type": "integer",
},
},
"required": []interface{} /* len=1 cap=1 */ {
"ID",
},
"title": "A",
"type": "object",
},
"B": map[string]interface{} /* len=6 */ {
`additionalProperties` /* len=20 */ : false,
"description": `github.com/NaturalSelectionLabs/jschema_test.B`, /* len=46 */
"properties": map[string]interface{}{
"A": map[string]interface{}{
"$ref": "#/$defs/A",
},
},
"required": []interface{} /* len=1 cap=1 */ {
"A",
},
"title": "B",
"type": "object",
},
},
"$ref": "#/$defs/B",
})
g.Eq(old, g.JSON(s.String()))
}