This repository was archived by the owner on Feb 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsubcommand_test.go
More file actions
68 lines (56 loc) · 1.46 KB
/
subcommand_test.go
File metadata and controls
68 lines (56 loc) · 1.46 KB
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
package flag
import (
"testing"
)
func TestSubCommand(t *testing.T) {
parent := NewParentCommand("test-subcommand")
clone, init, add, mv, reset, rm := false, false, false, false, false, false
parent.SubCommand("clone", "Clone a repository into a new directory", func() {
t.Logf("call clone subcommand")
clone = true
})
parent.SubCommand("init", "Create an empty Git repository or reinitialize an existing one", func() {
t.Logf("call init subcommand")
init = true
})
parent.SubCommand("add", "Add file contents to the index", func() {
t.Logf("call add subcommand")
add = true
})
parent.SubCommand("mv", "Move or rename a file, a directory, or a symlink", func() {
t.Logf("call mv subcommand")
mv = true
})
parent.SubCommand("reset", "Reset current HEAD to the specified state", func() {
t.Logf("call reset subcommand")
reset = true
})
parent.SubCommand("rm", "Remove files from the working tree and from the index", func() {
t.Logf("call rm subcommand")
rm = true
})
parent.Parse([]string{"clone"})
parent.Parse([]string{"init"})
parent.Parse([]string{"add"})
parent.Parse([]string{"mv"})
parent.Parse([]string{"reset"})
parent.Parse([]string{"rm"})
if !clone {
t.Error("clone should be true")
}
if !init {
t.Error("init should be true")
}
if !add {
t.Error("add should be true")
}
if !mv {
t.Error("mv should be true")
}
if !reset {
t.Error("reset should be true")
}
if !rm {
t.Error("rm should be true")
}
}