-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmetas_test.go
57 lines (46 loc) · 1.03 KB
/
metas_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 (
"gopkg.in/yaml.v2"
"testing"
)
func TestPolicyType_MarshalYAML(t *testing.T) {
t.Log(Must.MarshalYAML())
t.Log(Option.MarshalYAML())
}
func TestPolicyType_UnmarshalYAML(t *testing.T) {
var a PolicyType
yaml.Unmarshal([]byte("Must"), &a)
t.Log(a)
yaml.Unmarshal([]byte("Option"), &a)
t.Log(a)
e := yaml.Unmarshal([]byte("yes"), &a)
if e != nil {
t.Errorf("ummarshal error %s", e.Error())
}
t.Log(a)
}
func TestApi_LoadFromYaml(t *testing.T) {
var api Api
api.LoadFromYaml("apis/hello.yaml")
t.Log(api.Name, api.Methods)
t.Log(api.RequestSet.Style)
t.Log(api)
}
func TestValidatorType_UnmarshalYAML(t *testing.T) {
var vt ValidatorType
yaml.Unmarshal([]byte(""), &vt)
t.Log(vt)
yaml.Unmarshal([]byte("regex"), &vt)
t.Log(vt)
}
func TestParamter_Validate(t *testing.T) {
var api Api
api.LoadFromYaml("apis/hello.yaml")
p := api.RequestSet.Fields[0]
c := new(Config)
c.LoadFromYaml("configs.yaml")
t.Log(p)
t.Log(p.Validate("123"))
t.Log(p.Validate("abc"))
t.Log(p.Validate("123456789"))
}