diff --git a/testutils/testutils.go b/testutils/testutils.go index 4655e58..9c664ff 100644 --- a/testutils/testutils.go +++ b/testutils/testutils.go @@ -1,10 +1,15 @@ package testutils import ( + "math/rand" "testing" "time" ) +const chars = "abcdefghijklmnopqrstuvwxyz" + + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + + "~!@#$%^&*()-_+={}[]\\|<,>.?/\"';:` " + // Timeout calls f and waits for 100ms for it to complete. // If it doesn't, it causes the tests to fail. // t must be a valid testing context. @@ -21,3 +26,12 @@ func Timeout(t *testing.T, f func()) { case <-onDone: } } + +// RandomString returns random string of specified length +func RandomString(length int) string { + res := make([]byte, length) + for i := 0; i < length; i++ { + res[i] = chars[rand.Intn(len(chars))] + } + return string(res) +}