MCPcopy Index your code
hub / github.com/devspace-sh/devspace / TestGenerateRandomString

Function TestGenerateRandomString

pkg/util/randutil/rand_test.go:9–23  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestGenerateRandomString(t *testing.T) {
10 forbiddenCharsRegex := regexp.MustCompile("[^a-zA-Z0-9]")
11 for i := 0; i < 1000; i++ {
12 randString := GenerateRandomString(1)
13 if len(randString) != 1 {
14 t.Error("Random String has unexpected length.\nExpected: 1\nActual: " + strconv.Itoa(len(randString)))
15 t.Fail()
16 }
17
18 if forbiddenCharsRegex.Match([]byte(randString)) {
19 t.Error("Bad Character in generated String. Expected only letters and numbers. Acutal: " + randString)
20 t.Fail()
21 }
22 }
23}

Callers

nothing calls this directly

Calls 3

GenerateRandomStringFunction · 0.85
ErrorMethod · 0.45
FailMethod · 0.45

Tested by

no test coverage detected