This repository was archived by the owner on May 11, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli_test.go
More file actions
60 lines (50 loc) · 1.36 KB
/
cli_test.go
File metadata and controls
60 lines (50 loc) · 1.36 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
package main
import (
"flag"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCreateCommand(t *testing.T) {
bc := &BaseCommand{BinName: "test"}
cc := &CreateCommand{BaseCommand: bc, CmdName: "test"}
assert.Equal(t, cc.CmdName, cc.Name())
assert.NotEmpty(t, cc.Desc())
assert.Equal(t, 2, func() int {
var count int
cc.FlagSet().VisitAll(func(*flag.Flag) { count++ })
return count
}())
}
func TestAddCommand(t *testing.T) {
bc := &BaseCommand{BinName: "test"}
cc := &AddCommand{BaseCommand: bc, CmdName: "test"}
assert.Equal(t, cc.CmdName, cc.Name())
assert.NotEmpty(t, cc.Desc())
assert.Equal(t, 3, func() int {
var count int
cc.FlagSet().VisitAll(func(*flag.Flag) { count++ })
return count
}())
}
func TestWaitCommand(t *testing.T) {
bc := &BaseCommand{BinName: "test"}
cc := &WaitCommand{BaseCommand: bc, CmdName: "test"}
assert.Equal(t, cc.CmdName, cc.Name())
assert.NotEmpty(t, cc.Desc())
assert.Equal(t, 5, func() int {
var count int
cc.FlagSet().VisitAll(func(*flag.Flag) { count++ })
return count
}())
}
func TestHelpCommand(t *testing.T) {
bc := &BaseCommand{BinName: "test"}
cc := &HelpCommand{BaseCommand: bc, CmdName: "test"}
assert.Equal(t, cc.CmdName, cc.Name())
assert.NotEmpty(t, cc.Desc())
assert.Equal(t, 2, func() int {
var count int
cc.FlagSet().VisitAll(func(*flag.Flag) { count++ })
return count
}())
}