From c69f80c86c35b508ae21a7653e3e926e7c164e81 Mon Sep 17 00:00:00 2001 From: Yiqiao Pu Date: Tue, 29 May 2018 17:29:20 +0800 Subject: Add a function for e2e test to write json file This function is used to write json format configure files. Signed-off-by: Yiqiao Pu Closes: #837 Approved by: rhatdan --- test/e2e/libpod_suite_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/e2e/libpod_suite_test.go') diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go index 0c3dd2eea..796bf2199 100644 --- a/test/e2e/libpod_suite_test.go +++ b/test/e2e/libpod_suite_test.go @@ -629,6 +629,14 @@ func IsCommandAvailable(command string) bool { return true } +// WriteJsonFile write json format data to a json file +func WriteJsonFile(data []byte, filePath string) error { + var jsonData map[string]interface{} + json.Unmarshal(data, &jsonData) + formatJson, _ := json.MarshalIndent(jsonData, "", " ") + return ioutil.WriteFile(filePath, formatJson, 0644) +} + func getTestContext() context.Context { return context.Background() } -- cgit v1.2.3-54-g00ecf