MCPcopy Index your code
hub / github.com/redspread/spread / testRandomObjects

Function testRandomObjects

pkg/input/dir/source_test.go:354–372  ·  view source on GitHub ↗

testRandomObjects returns a slice of randomly generated objects. If it is called with an object count of < 0 a random number of slices (with an upper bound of 100) will be generated.

(num int)

Source from the content-addressed store, hash-verified

352// testRandomObjects returns a slice of randomly generated objects. If it is called with an object
353// count of < 0 a random number of slices (with an upper bound of 100) will be generated.
354func testRandomObjects(num int) (objects []deploy.KubeObject) {
355 if num < 0 {
356 num = rand.Intn(100)
357 }
358
359 for i := 0; i < num; i++ {
360 // TODO: create different types of objects
361 name := ""
362 for {
363 name = randomString(10)
364 if !TestUsedNames[name] {
365 break
366 }
367 }
368 TestUsedNames[name] = true
369 objects = append(objects, createSecret(name))
370 }
371 return
372}
373
374func randomString(strlen int) string {
375 const chars = "abcdefghijklmnopqrstuvwxyz0123456789"

Callers 2

testWriteRandomObjectsFunction · 0.70
TestSourceObjectsKubeDirFunction · 0.70

Calls 2

randomStringFunction · 0.70
createSecretFunction · 0.70

Tested by

no test coverage detected