-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli_test.go
More file actions
76 lines (59 loc) · 1.44 KB
/
cli_test.go
File metadata and controls
76 lines (59 loc) · 1.44 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
69
70
71
72
73
74
75
76
package cli
import (
"context"
"testing"
"github.com/krostar/test"
"github.com/krostar/test/check"
)
func Test_CLI(t *testing.T) {
cmd0 := new(command0)
cmd1 := new(command1)
cmd2 := new(command2)
cmd3 := new(command3)
cmd31 := new(command31)
cmd4 := new(command4)
cli := New(cmd0).
AddCommand("cmd1", cmd1).
AddCommand("cmd2", cmd2).
Mount("cmd3", New(cmd3).AddCommand("cmd31", cmd31)).
Mount("cmd4", New(cmd4))
test.Assert(check.Compare(t, cli, &CLI{
Command: cmd0,
SubCommands: []*CLI{
{
Name: "cmd1",
Command: cmd1,
},
{
Name: "cmd2",
Command: cmd2,
},
{
Name: "cmd3",
Command: cmd3,
SubCommands: []*CLI{
{
Name: "cmd31",
Command: cmd31,
},
},
},
{
Name: "cmd4",
Command: cmd4,
},
},
}))
}
type command0 struct{}
func (command0) Execute(context.Context, []string, []string) error { return nil }
type command1 struct{}
func (command1) Execute(context.Context, []string, []string) error { return nil }
type command2 struct{}
func (command2) Execute(context.Context, []string, []string) error { return nil }
type command3 struct{}
func (command3) Execute(context.Context, []string, []string) error { return nil }
type command31 struct{}
func (command31) Execute(context.Context, []string, []string) error { return nil }
type command4 struct{}
func (command4) Execute(context.Context, []string, []string) error { return nil }