-
Notifications
You must be signed in to change notification settings - Fork 5
/
completion_test.go
99 lines (73 loc) · 2.08 KB
/
completion_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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package main
import (
"bytes"
"testing"
"github.com/jovandeginste/payme/payment"
"github.com/stretchr/testify/assert"
)
func TestHelpCommand(t *testing.T) {
q := qrParams{
Payment: payment.New(),
}
cmdRoot, err := newCommand(&q)
assert.NoError(t, err)
actualOut := new(bytes.Buffer)
actualErr := new(bytes.Buffer)
cmdRoot.SetOut(actualOut)
cmdRoot.SetErr(actualErr)
cmdRoot.SetArgs([]string{"help"})
_, err = cmdRoot.ExecuteC()
assert.NoError(t, err)
assert.Contains(t, actualOut.String(), "Generate SEPA payment QR code")
assert.Empty(t, actualErr.String())
}
func TestCompletionHelp(t *testing.T) {
q := qrParams{
Payment: payment.New(),
}
cmdRoot, err := newCommand(&q)
assert.NoError(t, err)
actualOut := new(bytes.Buffer)
actualErr := new(bytes.Buffer)
cmdRoot.SetOut(actualOut)
cmdRoot.SetErr(actualErr)
cmdRoot.SetArgs([]string{"completion", "--help"})
_, err = cmdRoot.ExecuteC()
assert.NoError(t, err)
assert.Contains(t, actualOut.String(), "payme completion [bash|zsh|fish|powershell]")
assert.Empty(t, actualErr.String())
}
func TestCompletionShells(t *testing.T) {
q := qrParams{
Payment: payment.New(),
}
cmdRoot, err := newCommand(&q)
assert.NoError(t, err)
for _, shell := range []string{"bash", "zsh", "fish", "powershell"} {
actualOut := new(bytes.Buffer)
actualErr := new(bytes.Buffer)
cmdRoot.SetOut(actualOut)
cmdRoot.SetErr(actualErr)
cmdRoot.SetArgs([]string{"completion", shell})
_, err = cmdRoot.ExecuteC()
assert.NoError(t, err)
assert.Contains(t, actualOut.String(), shell+" completion for payme")
assert.Empty(t, actualErr.String())
}
}
func TestVersionCommand(t *testing.T) {
q := qrParams{
Payment: payment.New(),
}
cmdRoot, err := newCommand(&q)
assert.NoError(t, err)
actualOut := new(bytes.Buffer)
actualErr := new(bytes.Buffer)
cmdRoot.SetOut(actualOut)
cmdRoot.SetErr(actualErr)
cmdRoot.SetArgs([]string{"--version"})
_, err = cmdRoot.ExecuteC()
assert.NoError(t, err)
assert.Contains(t, actualOut.String(), "payme version local (local), built manually")
assert.Empty(t, actualErr.String())
}