-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathron_test.go
57 lines (50 loc) · 1.03 KB
/
ron_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
package ron
import (
"bytes"
"os"
"testing"
)
var (
wrkdir string
)
func init() {
wrkdir, _ = os.Getwd()
}
func TestRonRun(t *testing.T) {
stdOut := &bytes.Buffer{}
stdErr := &bytes.Buffer{}
c := NewDefaultCommander(stdOut, stdErr)
status, err := Run(c, []string{"version"})
if status != 0 {
t.Fatalf("expected status 0 got %d", status)
}
if err != nil {
t.Fatal(err)
}
}
func TestRonRunNArgs(t *testing.T) {
stdOut := &bytes.Buffer{}
stdErr := &bytes.Buffer{}
c := NewDefaultCommander(stdOut, stdErr)
status, _ := Run(c, []string{})
if status != 1 {
t.Fatalf("expected status 1 got %d", status)
}
}
func TestRonRunOutputStdout(t *testing.T) {
c := NewDefaultCommander(nil, nil)
status, err := Run(c, []string{"version"})
if status != 0 {
t.Fatalf("expected status 0 got %d", status)
}
if err != nil {
t.Fatal(err)
}
}
func TestRonRunNoCommand(t *testing.T) {
c := NewDefaultCommander(nil, nil)
status, _ := Run(c, []string{"nothere"})
if status != 1 {
t.Fatalf("expected status 1 got %d", status)
}
}