-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoption_test.go
75 lines (60 loc) · 2.5 KB
/
option_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
71
72
73
74
75
package commander
import (
"github.com/WindomZ/testify/assert"
"testing"
)
func TestOption_1(t *testing.T) {
o := newOption("-p", "add pepper")
assert.Equal(t, o.Names(), []string{"-p"})
assert.Equal(t, o.IsRequired(), false)
assert.Equal(t, o.IsOptional(), true)
assert.Equal(t, o.UsageString(), "[-p]")
assert.Equal(t, o.OptionString(), "-p add pepper")
}
func TestOption_2(t *testing.T) {
o := newOption("-p,--pepper", "add pepper")
assert.Equal(t, o.Names(), []string{"-p", "--pepper"})
assert.Equal(t, o.IsRequired(), false)
assert.Equal(t, o.IsOptional(), true)
assert.Equal(t, o.UsageString(), "[-p|--pepper]")
assert.Equal(t, o.OptionString(), "-p --pepper add pepper")
}
func TestOption_3(t *testing.T) {
o := newOption("-p=<path>|--pepper=<path>", "add pepper directory")
assert.Equal(t, o.Names(), []string{"-p", "--pepper"})
assert.Equal(t, o.IsRequired(), false)
assert.Equal(t, o.IsOptional(), true)
assert.Equal(t, o.UsageString(), "[-p=<path>|--pepper=<path>]")
assert.Equal(t, o.OptionString(), "-p=<path> --pepper=<path>\n add pepper directory")
}
func TestOption_4(t *testing.T) {
o := newOption("[-p=[path],--pepper=[path]]", "add pepper directory", func() {}, "xxx")
assert.Equal(t, o.Names(), []string{"-p", "--pepper"})
assert.Equal(t, o.IsRequired(), false)
assert.Equal(t, o.IsOptional(), true)
assert.Equal(t, o.UsageString(), "[-p=[path]|--pepper=[path]]")
assert.Equal(t, o.OptionString(), "-p=[path] --pepper=[path]\n add pepper directory [default: xxx]")
}
func TestOption_5(t *testing.T) {
o := newOption("-p=[path]", "add pepper directory", func() {}, "xxx")
assert.Equal(t, o.Names(), []string{"-p"})
assert.Equal(t, o.IsRequired(), false)
assert.Equal(t, o.IsOptional(), true)
assert.Equal(t, o.UsageString(), "[-p=[path]]")
assert.Equal(t, o.OptionString(), "-p=[path] add pepper directory [default: xxx]")
}
func TestOption_6(t *testing.T) {
o := newOption("(-p=[path])", "add pepper directory", func() {}, "xxx")
assert.Equal(t, o.Names(), []string{"-p"})
assert.Equal(t, o.IsRequired(), true)
assert.Equal(t, o.IsOptional(), false)
assert.Equal(t, o.UsageString(), "(-p=[path])")
assert.Equal(t, o.OptionString(), "-p=[path] add pepper directory [default: xxx]")
}
func TestOption_7(t *testing.T) {
o := newOption("(-p=[path])", "", func() {}, "xxx")
assert.Equal(t, o.Names(), []string{"-p"})
assert.Equal(t, o.IsRequired(), true)
assert.Equal(t, o.IsOptional(), false)
assert.Equal(t, o.UsageString(), "(-p=[path])")
}