summaryrefslogtreecommitdiff
path: root/test/utils/utils.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-12-08 15:30:31 -0500
committerGitHub <noreply@github.com>2020-12-08 15:30:31 -0500
commit7caef9c497da0c2a16caf4f15152bc543dfb6008 (patch)
tree8b14a4ebde2b3ecc5ab8ec5f5f4b13a034661b17 /test/utils/utils.go
parent7b2e81ec268464427e4d1365cbdd9e0bc9c582f5 (diff)
parentce474788fd9bcecdb1cd6730fecd16e5d8840ae5 (diff)
downloadpodman-7caef9c497da0c2a16caf4f15152bc543dfb6008.tar.gz
podman-7caef9c497da0c2a16caf4f15152bc543dfb6008.tar.bz2
podman-7caef9c497da0c2a16caf4f15152bc543dfb6008.zip
Merge pull request #8642 from jwhonce/issues/8444
Restore json format for fields as well as whole structs
Diffstat (limited to 'test/utils/utils.go')
-rw-r--r--test/utils/utils.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/utils/utils.go b/test/utils/utils.go
index d08939678..027e96427 100644
--- a/test/utils/utils.go
+++ b/test/utils/utils.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
+ "math/rand"
"os"
"os/exec"
"runtime"
@@ -465,3 +466,16 @@ func Containerized() bool {
}
return false
}
+
+var randomLetters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
+
+// RandomString returns a string of given length composed of random characters
+func RandomString(n int) string {
+ rand.Seed(GinkgoRandomSeed())
+
+ b := make([]rune, n)
+ for i := range b {
+ b[i] = randomLetters[rand.Intn(len(randomLetters))]
+ }
+ return string(b)
+}