summaryrefslogtreecommitdiff
path: root/test/utils
diff options
context:
space:
mode:
Diffstat (limited to 'test/utils')
-rw-r--r--test/utils/common_function_test.go6
-rw-r--r--test/utils/podmantest_test.go12
-rw-r--r--test/utils/utils.go4
3 files changed, 7 insertions, 15 deletions
diff --git a/test/utils/common_function_test.go b/test/utils/common_function_test.go
index a73d75490..7092e40a1 100644
--- a/test/utils/common_function_test.go
+++ b/test/utils/common_function_test.go
@@ -113,8 +113,10 @@ var _ = Describe("Common functions test", func() {
Expect(err).To(BeNil(), "Can not find the JSON file after we write it.")
defer read.Close()
- bytes, _ := ioutil.ReadAll(read)
- json.Unmarshal(bytes, compareData)
+ bytes, err := ioutil.ReadAll(read)
+ Expect(err).ToNot(HaveOccurred())
+ err = json.Unmarshal(bytes, compareData)
+ Expect(err).ToNot(HaveOccurred())
Expect(reflect.DeepEqual(testData, compareData)).To(BeTrue(), "Data changed after we store it to file.")
})
diff --git a/test/utils/podmantest_test.go b/test/utils/podmantest_test.go
index a9b5aef1f..26d359d38 100644
--- a/test/utils/podmantest_test.go
+++ b/test/utils/podmantest_test.go
@@ -1,8 +1,6 @@
package utils_test
import (
- "os"
-
. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -19,16 +17,6 @@ var _ = Describe("PodmanTest test", func() {
FakeOutputs = make(map[string][]string)
})
- It("Test PodmanAsUserBase", func() {
- FakeOutputs["check"] = []string{"check"}
- os.Setenv("HOOK_OPTION", "hook_option")
- env := os.Environ()
- session := podmanTest.PodmanAsUserBase([]string{"check"}, 1000, 1000, "", env, true, false, nil, nil)
- os.Unsetenv("HOOK_OPTION")
- session.WaitWithDefaultTimeout()
- Expect(session.Command.Process).ShouldNot(BeNil())
- })
-
It("Test NumberOfContainersRunning", func() {
FakeOutputs["ps -q"] = []string{"one", "two"}
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2))
diff --git a/test/utils/utils.go b/test/utils/utils.go
index f3e14c784..36f5a9414 100644
--- a/test/utils/utils.go
+++ b/test/utils/utils.go
@@ -489,7 +489,9 @@ func IsCommandAvailable(command string) bool {
// 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)
+ if err := json.Unmarshal(data, &jsonData); err != nil {
+ return err
+ }
formatJSON, err := json.MarshalIndent(jsonData, "", " ")
if err != nil {
return err