Mercurial > yakumo_izuru > aya
comparison zs_test.go @ 5:e0ee0721d34f draft
added tests for eval command runner
author | zaitsev.serge |
---|---|
date | Fri, 05 Dec 2014 18:21:42 +0000 |
parents | 05fc24caac37 |
children | cb66f5b86616 |
comparison
equal
deleted
inserted
replaced
4:05fc24caac37 | 5:e0ee0721d34f |
---|---|
3 import ( | 3 import ( |
4 "bytes" | 4 "bytes" |
5 "fmt" | 5 "fmt" |
6 "log" | 6 "log" |
7 "os" | 7 "os" |
8 "os/exec" | |
8 "strings" | 9 "strings" |
9 "testing" | 10 "testing" |
10 ) | 11 ) |
11 | 12 |
12 func TestSplit2(t *testing.T) { | 13 func TestSplit2(t *testing.T) { |
121 if out.String() != "foo\n" { | 122 if out.String() != "foo\n" { |
122 t.Error(out.String()) | 123 t.Error(out.String()) |
123 } | 124 } |
124 } | 125 } |
125 | 126 |
127 func TestEvalCommand(t *testing.T) { | |
128 s, err := eval([]string{"echo", "hello"}, map[string]string{}) | |
129 if err != nil { | |
130 t.Error(err) | |
131 } | |
132 if s != "hello\n" { | |
133 t.Error(s) | |
134 } | |
135 _, err = eval([]string{"cat", "bogus/file"}, map[string]string{}) | |
136 if _, ok := err.(*exec.ExitError); !ok { | |
137 t.Error("expected ExitError") | |
138 } | |
139 _, err = eval([]string{"missing command"}, map[string]string{}) | |
140 if err != nil { | |
141 t.Error("missing command should be ignored") | |
142 } | |
143 } | |
144 | |
126 func TestHelperProcess(*testing.T) { | 145 func TestHelperProcess(*testing.T) { |
127 if os.Getenv("ZS_HELPER") != "1" { | 146 if os.Getenv("ZS_HELPER") != "1" { |
128 return | 147 return |
129 } | 148 } |
130 defer os.Exit(0) // TODO check exit code | 149 defer os.Exit(0) // TODO check exit code |