summaryrefslogtreecommitdiff
path: root/test/utils/utils.go
diff options
context:
space:
mode:
authorEd Santiago <santiago@redhat.com>2021-11-23 11:12:34 -0700
committerEd Santiago <santiago@redhat.com>2021-11-29 08:30:00 -0700
commitb63d696405593d056cce850e1503a6bef17c2cf8 (patch)
tree77aa079636ea326eec76520734e0ae9e815ca6c2 /test/utils/utils.go
parent3d19f1a7fac5705518693cad3f2c7f94dcc2f1d4 (diff)
downloadpodman-b63d696405593d056cce850e1503a6bef17c2cf8.tar.gz
podman-b63d696405593d056cce850e1503a6bef17c2cf8.tar.bz2
podman-b63d696405593d056cce850e1503a6bef17c2cf8.zip
e2e tests: enable golint
...and fix problems found therewith. Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test/utils/utils.go')
-rw-r--r--test/utils/utils.go26
1 files changed, 9 insertions, 17 deletions
diff --git a/test/utils/utils.go b/test/utils/utils.go
index 4a57d9ce7..944c1ac3c 100644
--- a/test/utils/utils.go
+++ b/test/utils/utils.go
@@ -13,9 +13,9 @@ import (
"time"
"github.com/containers/storage/pkg/parsers/kernel"
- . "github.com/onsi/ginkgo"
- . "github.com/onsi/gomega"
- . "github.com/onsi/gomega/gexec"
+ . "github.com/onsi/ginkgo" //nolint:golint,stylecheck
+ . "github.com/onsi/gomega" //nolint:golint,stylecheck
+ . "github.com/onsi/gomega/gexec" //nolint:golint,stylecheck
)
var (
@@ -439,25 +439,21 @@ func IsKernelNewerThan(version string) (bool, error) {
return true, nil
}
return false, nil
-
}
// IsCommandAvailable check if command exist
func IsCommandAvailable(command string) bool {
check := exec.Command("bash", "-c", strings.Join([]string{"command -v", command}, " "))
err := check.Run()
- if err != nil {
- return false
- }
- return true
+ return err == nil
}
-// WriteJsonFile write json format data to a json file
-func WriteJsonFile(data []byte, filePath string) error {
+// 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)
+ formatJSON, _ := json.MarshalIndent(jsonData, "", " ")
+ return ioutil.WriteFile(filePath, formatJSON, 0644)
}
// Containerized check the podman command run inside container
@@ -471,10 +467,7 @@ func Containerized() bool {
// shrug, if we cannot read that file, return false
return false
}
- if strings.Index(string(b), "docker") > -1 {
- return true
- }
- return false
+ return strings.Contains(string(b), "docker")
}
func init() {
@@ -485,7 +478,6 @@ var randomLetters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
// RandomString returns a string of given length composed of random characters
func RandomString(n int) string {
-
b := make([]rune, n)
for i := range b {
b[i] = randomLetters[rand.Intn(len(randomLetters))]