diff options
author | Valentin Rothberg <vrothberg@redhat.com> | 2022-03-21 13:47:59 +0100 |
---|---|---|
committer | Valentin Rothberg <vrothberg@redhat.com> | 2022-03-22 13:04:35 +0100 |
commit | f72a678f2a06697ff42e1fe5636cb09b47a25b49 (patch) | |
tree | 8f6f5c210d474086f70b826118cd6558ee8fc4e3 /test | |
parent | bb6b69b4abe86601a8438a6708263174879b5c51 (diff) | |
download | podman-f72a678f2a06697ff42e1fe5636cb09b47a25b49.tar.gz podman-f72a678f2a06697ff42e1fe5636cb09b47a25b49.tar.bz2 podman-f72a678f2a06697ff42e1fe5636cb09b47a25b49.zip |
linter: enable errchkjson
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/utils/common_function_test.go | 5 | ||||
-rw-r--r-- | test/utils/utils.go | 5 |
2 files changed, 7 insertions, 3 deletions
diff --git a/test/utils/common_function_test.go b/test/utils/common_function_test.go index 810d9f2a5..144d8d4f1 100644 --- a/test/utils/common_function_test.go +++ b/test/utils/common_function_test.go @@ -102,9 +102,10 @@ var _ = Describe("Common functions test", func() { Item2: []string{"test"}, } - testByte, _ := json.Marshal(testData) - err := WriteJSONFile(testByte, "/tmp/testJSON") + testByte, err := json.Marshal(testData) + Expect(err).To(BeNil(), "Failed to marshal data.") + err = WriteJSONFile(testByte, "/tmp/testJSON") Expect(err).To(BeNil(), "Failed to write JSON to file.") read, err := os.Open("/tmp/testJSON") diff --git a/test/utils/utils.go b/test/utils/utils.go index 8fe45dca0..a6295cd19 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -479,7 +479,10 @@ func IsCommandAvailable(command string) bool { func WriteJSONFile(data []byte, filePath string) error { var jsonData map[string]interface{} json.Unmarshal(data, &jsonData) - formatJSON, _ := json.MarshalIndent(jsonData, "", " ") + formatJSON, err := json.MarshalIndent(jsonData, "", " ") + if err != nil { + return err + } return ioutil.WriteFile(filePath, formatJSON, 0644) } |