-
Notifications
You must be signed in to change notification settings - Fork 4
/
main_test.go
57 lines (53 loc) · 1.18 KB
/
main_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
package main
import (
"io/ioutil"
"os"
"testing"
)
func TestGenerateStructFile(t *testing.T) {
pkg := "taskyapi"
op := ioutil.Discard
cases := []struct {
Validator bool
UseTitle bool
Nullable bool
}{
{Validator: false, UseTitle: false, Nullable: false},
{Validator: true, UseTitle: false, Nullable: false},
{Validator: true, UseTitle: true, Nullable: true},
}
for _, c := range cases {
fp, err := os.Open("./example/doc/schema/schema.json")
if err != nil {
t.Fatal(err)
}
if err := generateStructFile(&pkg, fp, op, c.Validator, c.UseTitle, c.Nullable); err != nil {
t.Fatal(err)
}
fp.Close()
}
}
func TestGenerateJsValValidatorFile(t *testing.T) {
pkg := "taskyapi"
fp, err := os.Open("./example/doc/schema/schema.json")
if err != nil {
t.Fatal(err)
}
defer fp.Close()
op := ioutil.Discard
if err := generateJsValValidatorFile(&pkg, fp, op); err != nil {
t.Fatal(err)
}
}
func TestGenerateValidatorFile(t *testing.T) {
pkg := "taskyapi"
fp, err := os.Open("./example/doc/schema/schema.json")
if err != nil {
t.Fatal(err)
}
defer fp.Close()
op := ioutil.Discard
if err := generateValidatorFile(&pkg, fp, op); err != nil {
t.Fatal(err)
}
}