-
Notifications
You must be signed in to change notification settings - Fork 4
/
parser_test.go
70 lines (62 loc) · 1.21 KB
/
parser_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
63
64
65
66
67
68
69
70
package main
import (
"testing"
schema "github.com/lestrrat-go/jsschema"
)
func testNewParser(t *testing.T) *Parser {
sc, err := schema.ReadFile("./example/doc/schema/schema.json")
if err != nil {
t.Fatal(err)
}
return &Parser{
schema: sc,
pkgName: "model",
}
}
func TestParseResources(t *testing.T) {
parser := testNewParser(t)
res, err := parser.ParseResources()
if err != nil {
t.Fatal(err)
}
for key, r := range res {
t.Logf("%s/%s", key, r.Name)
}
}
func TestParseJsValValidators(t *testing.T) {
parser := testNewParser(t)
vals, err := parser.ParseJsValValidators()
if err != nil {
t.Fatal(err)
}
for _, v := range vals {
t.Logf("%s", v.Name)
}
}
func TestParseValidators(t *testing.T) {
parser := testNewParser(t)
vals, err := parser.ParseValidators()
if err != nil {
t.Fatal(err)
}
for _, v := range vals {
t.Logf("%s", v.Name)
}
}
func TestParseActions(t *testing.T) {
parser := testNewParser(t)
r, err := parser.ParseResources()
if err != nil {
t.Fatal(err)
}
res, err := parser.ParseActions(r)
if err != nil {
t.Fatal(err)
}
for key, actions := range res {
t.Log(key)
for _, action := range actions {
t.Logf(" %s: %s", action.Method, action.Href)
}
}
}