aboutsummaryrefslogtreecommitdiff
path: root/test/utils
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-12-07 15:34:14 -0700
committerJhon Honce <jhonce@redhat.com>2020-12-07 15:39:43 -0700
commitce474788fd9bcecdb1cd6730fecd16e5d8840ae5 (patch)
tree1ddff0e68cb8a53244956212947cd8b37a301d87 /test/utils
parente2f91207fc3e515c0a9f828433aaf80727f4b7c5 (diff)
downloadpodman-ce474788fd9bcecdb1cd6730fecd16e5d8840ae5.tar.gz
podman-ce474788fd9bcecdb1cd6730fecd16e5d8840ae5.tar.bz2
podman-ce474788fd9bcecdb1cd6730fecd16e5d8840ae5.zip
Restore json format for fields as well as whole structs
* Add template func to inspect template processing * Added test using repro from #8444 Fixes #8444 Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'test/utils')
-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)
+}