forked from rancher/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
64 lines (52 loc) · 1.34 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
58
59
60
61
62
63
64
package main
import (
"testing"
"gopkg.in/check.v1"
)
// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) {
check.TestingT(t)
}
type MainTestSuite struct {
}
var _ = check.Suite(&MainTestSuite{})
func (m *MainTestSuite) SetUpSuite(c *check.C) {
}
func (m *MainTestSuite) TestParseArgs(c *check.C) {
input := [][]string{
{"rancher", "run", "--debug", "-itd"},
{"rancher", "run", "--debug", "-itf=b"},
{"rancher", "run", "--debug", "-itd#"},
{"rancher", "run", "--debug", "-f=b"},
{"rancher", "run", "--debug", "-=b"},
{"rancher", "run", "--debug", "-"},
}
r0, err := parseArgs(input[0])
if err != nil {
c.Fatal(err)
}
c.Assert(r0, check.DeepEquals, []string{"rancher", "run", "--debug", "-i", "-t", "-d"})
r1, err := parseArgs(input[1])
if err != nil {
c.Fatal(err)
}
c.Assert(r1, check.DeepEquals, []string{"rancher", "run", "--debug", "-i", "-t", "-f=b"})
_, err = parseArgs(input[2])
if err == nil {
c.Fatal("should raise error")
}
r3, err := parseArgs(input[3])
if err != nil {
c.Fatal(err)
}
c.Assert(r3, check.DeepEquals, []string{"rancher", "run", "--debug", "-f=b"})
_, err = parseArgs(input[4])
if err == nil {
c.Fatal("should raise error")
}
r5, err := parseArgs(input[5])
if err != nil {
c.Fatal(err)
}
c.Assert(r5, check.DeepEquals, []string{"rancher", "run", "--debug", "-"})
}