MCPcopy Create free account
hub / github.com/Percona-Lab/mysql_random_data_load / WriteJson

Function WriteJson

testutils/testutils.go:184–196  ·  view source on GitHub ↗
(tb testing.TB, filename string, data interface{})

Source from the content-addressed store, hash-verified

182}
183
184func 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.
199func Assert(tb testing.TB, condition bool, msg string, v ...interface{}) {

Callers 1

UpdateSampleJSONFunction · 0.85

Calls 1

callerFunction · 0.85

Tested by

no test coverage detected