forked from datreeio/datree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
63 lines (44 loc) · 1.34 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
63
package completion
import (
"bytes"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_ExecuteCommand(t *testing.T) {
t.Run("Test Completion Bash", func(t *testing.T) {
cmd := New()
out = new(bytes.Buffer)
cmd.SetArgs([]string{"bash"})
cmd.Execute()
got := out.(*bytes.Buffer).Bytes()
expected := []byte(`# bash completion for completion`)
assert.Equal(t, string(expected), string(got)[:len(expected)])
})
t.Run("Test Completion Zsh", func(t *testing.T) {
cmd := New()
out = new(bytes.Buffer)
cmd.SetArgs([]string{"zsh"})
cmd.Execute()
got := out.(*bytes.Buffer).Bytes()
expected := []byte(`#compdef completion`)
assert.Equal(t, string(expected), string(got)[:len(expected)])
})
t.Run("Test Completion Fish", func(t *testing.T) {
cmd := New()
out = new(bytes.Buffer)
cmd.SetArgs([]string{"fish"})
cmd.Execute()
got := out.(*bytes.Buffer).Bytes()
expected := []byte(`# fish completion for completion`)
assert.Equal(t, string(expected), string(got)[:len(expected)])
})
t.Run("Test Completion Powershell", func(t *testing.T) {
cmd := New()
out = new(bytes.Buffer)
cmd.SetArgs([]string{"powershell"})
cmd.Execute()
got := out.(*bytes.Buffer).Bytes()
expected := []byte(`# powershell completion for completion`)
assert.Equal(t, string(expected), string(got)[:len(expected)])
})
}