-
Notifications
You must be signed in to change notification settings - Fork 123
/
main_test.go
62 lines (59 loc) · 1.98 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
package main
import (
"strings"
"testing"
)
func TestIsCompletionCmd(t *testing.T) {
for args, is := range map[string]bool{
"": false,
"something": false,
"something something": false,
"completion for my bash script how to": false,
"completion bash how to": false,
"completion": false,
"completion -h": true,
"completion --help": true,
"completion help": true,
"completion bash": true,
"completion fish": true,
"completion zsh": true,
"completion powershell": true,
"completion bash -h": true,
"completion fish -h": true,
"completion zsh -h": true,
"completion powershell -h": true,
"completion bash --help": true,
"completion fish --help": true,
"completion zsh --help": true,
"completion powershell --help": true,
"__complete": true,
"__complete blah blah blah": true,
} {
t.Run(args, func(t *testing.T) {
vargs := append([]string{"mods"}, strings.Fields(args)...)
if b := isCompletionCmd(vargs); b != is {
t.Errorf("%v: expected %v, got %v", vargs, is, b)
}
})
}
}
func TestIsManCmd(t *testing.T) {
for args, is := range map[string]bool{
"": false,
"something": false,
"something something": false,
"man is no more": false,
"mans": false,
"man foo": false,
"man": true,
"man -h": true,
"man --help": true,
} {
t.Run(args, func(t *testing.T) {
vargs := append([]string{"mods"}, strings.Fields(args)...)
if b := isManCmd(vargs); b != is {
t.Errorf("%v: expected %v, got %v", vargs, is, b)
}
})
}
}