Mercurial > yakumo_izuru > aya
diff 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 |
line wrap: on
line diff
--- a/zs_test.go Fri Dec 05 18:09:03 2014 +0000 +++ b/zs_test.go Fri Dec 05 18:21:42 2014 +0000 @@ -5,6 +5,7 @@ "fmt" "log" "os" + "os/exec" "strings" "testing" ) @@ -123,6 +124,24 @@ } } +func TestEvalCommand(t *testing.T) { + s, err := eval([]string{"echo", "hello"}, map[string]string{}) + if err != nil { + t.Error(err) + } + if s != "hello\n" { + t.Error(s) + } + _, err = eval([]string{"cat", "bogus/file"}, map[string]string{}) + if _, ok := err.(*exec.ExitError); !ok { + t.Error("expected ExitError") + } + _, err = eval([]string{"missing command"}, map[string]string{}) + if err != nil { + t.Error("missing command should be ignored") + } +} + func TestHelperProcess(*testing.T) { if os.Getenv("ZS_HELPER") != "1" { return