(tb testing.TB, filename string, data interface{})
| 182 | } |
| 183 | |
| 184 | func WriteJson(tb testing.TB, filename string, data interface{}) { |
| 185 | file := filepath.Join("testdata", filename) |
| 186 | buf, err := json.MarshalIndent(data, "", " ") |
| 187 | if err != nil { |
| 188 | fmt.Printf("%s cannot marshal %T into %q: %s\n\n", caller(), data, file, err) |
| 189 | tb.FailNow() |
| 190 | } |
| 191 | err = ioutil.WriteFile(file, buf, os.ModePerm) |
| 192 | if err != nil { |
| 193 | fmt.Printf("%s cannot write file %q: %s\n\n", caller(), file, err) |
| 194 | tb.FailNow() |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | // assert fails the test if the condition is false. |
| 199 | func Assert(tb testing.TB, condition bool, msg string, v ...interface{}) { |
no test coverage detected