-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcommand_list_test.go
More file actions
39 lines (31 loc) · 711 Bytes
/
command_list_test.go
File metadata and controls
39 lines (31 loc) · 711 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
37
38
39
package main
import (
"strings"
"testing"
"github.com/andreyvit/diff"
"github.com/urfave/cli"
)
const expected = `
uncommitted changes
D Go.gitignore
M Node.gitignore
?? newfile
unpushed commits
`
func TestCommandList(t *testing.T) {
app := cli.NewApp()
app.Flags = flagsOfList
app.Action = doList
var err error
out := captureStdout(func() {
err = app.Run([]string{"gst"})
})
if err != nil {
t.Errorf("Unexpected exit code: %s", err)
}
line := strings.Split(strings.TrimSpace(out), "\n")
truncated := strings.Join(line[1:len(line)-1], "\n")
if a, e := strings.TrimSpace(truncated), strings.TrimSpace(expected); a != e {
t.Errorf("Unexpected output\n%v", diff.LineDiff(e, a))
}
}