forked from cli/cli
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompletion_test.go
More file actions
57 lines (47 loc) · 1.22 KB
/
completion_test.go
File metadata and controls
57 lines (47 loc) · 1.22 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
package command
import (
"strings"
"testing"
)
func TestCompletion_bash(t *testing.T) {
output, err := RunCommand(`completion`)
if err != nil {
t.Fatal(err)
}
if !strings.Contains(output.String(), "complete -o default -F __start_gh gh") {
t.Errorf("problem in bash completion:\n%s", output)
}
}
func TestCompletion_zsh(t *testing.T) {
output, err := RunCommand(`completion -s zsh`)
if err != nil {
t.Fatal(err)
}
if !strings.Contains(output.String(), "#compdef _gh gh") {
t.Errorf("problem in zsh completion:\n%s", output)
}
}
func TestCompletion_fish(t *testing.T) {
output, err := RunCommand(`completion -s fish`)
if err != nil {
t.Fatal(err)
}
if !strings.Contains(output.String(), "complete -c gh ") {
t.Errorf("problem in fish completion:\n%s", output)
}
}
func TestCompletion_powerShell(t *testing.T) {
output, err := RunCommand(`completion -s powershell`)
if err != nil {
t.Fatal(err)
}
if !strings.Contains(output.String(), "Register-ArgumentCompleter") {
t.Errorf("problem in powershell completion:\n%s", output)
}
}
func TestCompletion_unsupported(t *testing.T) {
_, err := RunCommand(`completion -s csh`)
if err == nil || err.Error() != `unsupported shell type "csh"` {
t.Fatal(err)
}
}