-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_test.go
44 lines (37 loc) · 884 Bytes
/
cmd_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 bin
import "testing"
func TestApp_GetDoc(t *testing.T) {
a := &App{
Title: "uymas",
Description: "the standard(beautiful) format cmd application",
CmdList: []AppCmd{
{
Alias: []string{"-n"},
Name: "name",
Title: "设置或查看 name 属性",
Option: nil,
Register: nil,
},
},
}
t.Logf("\n" + a.GetDoc())
}
func TestAppOptionGroup_ParseEach(t *testing.T) {
aop := &AppOptionGroup{}
type testOption struct {
Url string `cmd:"url, u; required"`
}
var vop testOption
err := aop.ParseEach(&vop, func(opt *AppOption) {
})
if err != nil {
t.Errorf("Parse Error: %v", err)
}
url := aop.Option("url")
if url.Name != "url" {
t.Errorf("the name of Url param parse error!")
}
if url.Validation != OptValidationRequire {
t.Errorf("Url parse error,(%v != %v)!", url.Validation, OptValidationRequire)
}
}