Mercurial > yakumo_izuru > aya
comparison zs_test.go @ 23:40f55059fbfa draft
fixed output file names in html pages, fixed amber function bindings, replaced print command with build, fixed plugin functions, implemented zs and exec functions
author | zaitsev.serge |
---|---|
date | Sun, 30 Aug 2015 12:20:35 +0000 |
parents | 802b96e67bae |
children | e3c902a7380d |
comparison
equal
deleted
inserted
replaced
22:f5627d4212a3 | 23:40f55059fbfa |
---|---|
4 "bytes" | 4 "bytes" |
5 "fmt" | 5 "fmt" |
6 "io/ioutil" | 6 "io/ioutil" |
7 "log" | 7 "log" |
8 "os" | 8 "os" |
9 "os/exec" | |
10 "strings" | 9 "strings" |
11 "testing" | 10 "testing" |
12 "text/template" | |
13 ) | 11 ) |
14 | 12 |
15 func TestSplit2(t *testing.T) { | 13 func TestSplit2(t *testing.T) { |
16 if a, b := split2("a:b", ":"); a != "a" || b != "b" { | 14 if a, b := split2("a:b", ":"); a != "a" || b != "b" { |
17 t.Fail() | 15 t.Fail() |
76 } | 74 } |
77 } | 75 } |
78 | 76 |
79 func TestRender(t *testing.T) { | 77 func TestRender(t *testing.T) { |
80 vars := map[string]string{"foo": "bar"} | 78 vars := map[string]string{"foo": "bar"} |
81 funcs := template.FuncMap{ | 79 funcs := Funcs{ |
82 "greet": func(s ...string) string { | 80 "greet": func(s ...string) string { |
83 if len(s) == 0 { | 81 if len(s) == 0 { |
84 return "hello" | 82 return "hello" |
85 } else { | 83 } else { |
86 return "hello " + strings.Join(s, " ") | 84 return "hello " + strings.Join(s, " ") |
136 if out.String() != "foo\n" { | 134 if out.String() != "foo\n" { |
137 t.Error(out.String()) | 135 t.Error(out.String()) |
138 } | 136 } |
139 } | 137 } |
140 | 138 |
141 func TestEvalCommand(t *testing.T) { | |
142 s, err := eval([]string{"echo", "hello"}, map[string]string{}) | |
143 if err != nil { | |
144 t.Error(err) | |
145 } | |
146 if s != "hello\n" { | |
147 t.Error(s) | |
148 } | |
149 _, err = eval([]string{"cat", "bogus/file"}, map[string]string{}) | |
150 if _, ok := err.(*exec.ExitError); !ok { | |
151 t.Error("expected ExitError") | |
152 } | |
153 _, err = eval([]string{"missing command"}, map[string]string{}) | |
154 if err != nil { | |
155 t.Error("missing command should be ignored") | |
156 } | |
157 } | |
158 | |
159 func TestHelperProcess(*testing.T) { | 139 func TestHelperProcess(*testing.T) { |
160 if os.Getenv("ZS_HELPER") != "1" { | 140 if os.Getenv("ZS_HELPER") != "1" { |
161 return | 141 return |
162 } | 142 } |
163 defer os.Exit(0) // TODO check exit code | 143 defer os.Exit(0) // TODO check exit code |