-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommand_test.go
60 lines (47 loc) · 1.02 KB
/
command_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
package main
import (
"testing"
"github.com/rendon/testcli"
)
func goRun(arg ...string) *testcli.Cmd {
c := testcli.Command("go", append([]string{
"run",
"format.go",
"flag.go",
"mog.go",
"command.go",
}, arg...)...)
return c
}
func TestHelp(t *testing.T) {
c := goRun("--help")
c.Run()
if !c.Success() {
t.Fatalf("Expected to succeed, but failed with error: %s", c.Error())
}
}
func TestVersion(t *testing.T) {
version := "v0.1.6"
c := goRun("--version")
c.Run()
if !c.Success() {
t.Fatalf("Expected to succeed, but failed with error: %s", c.Error())
}
if !c.StdoutContains(version) {
t.Fatalf("Expected %q to contain %q", c.Stdout(), version)
}
}
func TestStatusFailed(t *testing.T) {
c := goRun("status")
c.Run()
if !c.Failure() {
t.Fatalf("Expected to fail, but succeed: %s", c.Error())
}
}
func TestStatus(t *testing.T) {
c := goRun("status", "-s", "2017-06-24", "-w", "test", "+test+setup")
c.Run()
if !c.Failure() {
t.Fatalf("Expected to fail, but succeed: %s", c.Error())
}
}