forked from cli/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathargs_test.go
More file actions
50 lines (45 loc) · 934 Bytes
/
args_test.go
File metadata and controls
50 lines (45 loc) · 934 Bytes
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
package cmdutil
import "testing"
func TestMinimumArgs(t *testing.T) {
tests := []struct {
N int
Args []string
}{
{
N: 1,
Args: []string{"v1.2.3"},
},
{
N: 2,
Args: []string{"v1.2.3", "cli/cli"},
},
}
for _, test := range tests {
if got := MinimumArgs(test.N, "")(nil, test.Args); got != nil {
t.Errorf("Got: %v, Want: (nil)", got)
}
}
}
func TestMinimumNs_with_error(t *testing.T) {
tests := []struct {
N int
CustomMessage string
WantMessage string
}{
{
N: 1,
CustomMessage: "A custom msg",
WantMessage: "A custom msg",
},
{
N: 1,
CustomMessage: "",
WantMessage: "requires at least 1 arg(s), only received 0",
},
}
for _, test := range tests {
if got := MinimumArgs(test.N, test.CustomMessage)(nil, nil); got.Error() != test.WantMessage {
t.Errorf("Got: %v, Want: %v", got, test.WantMessage)
}
}
}