-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhush_test.go
More file actions
36 lines (33 loc) · 776 Bytes
/
hush_test.go
File metadata and controls
36 lines (33 loc) · 776 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
package hush
import (
"bytes"
"testing"
"github.com/fatih/color"
)
func TestRun(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
input string
expectCode int
expectOut string
}{
{
input: "ls",
expectOut: color.GreenString("➜") + " hush $ ls",
},
} {
tc := tc // Enable parallel sub-tests
t.Run(tc.input, func(t *testing.T) {
t.Parallel()
var in, out bytes.Buffer
exitCode := run(&in, &out, &out, []string{"hush", "-c", tc.input})
output := out.String()
if tc.expectCode != exitCode {
t.Errorf("Unexpected exit code.\nExpected: %d\nActual: %d", tc.expectCode, exitCode)
}
if tc.expectOut != output {
t.Errorf("Unexpected output.\nExpected: %s\nActual: %s", tc.expectOut, output)
}
})
}
}