MCPcopy Create free account
hub / github.com/devfile/api / RunTest

Method RunTest

test/v200/utils/common/test_utils.go:323–374  ·  view source on GitHub ↗

Runs a test to create and verify a devfile based on the content of the specified TestContent

(testContent TestContent, t *testing.T)

Source from the content-addressed store, hash-verified

321
322// Runs a test to create and verify a devfile based on the content of the specified TestContent
323func (testDevfile *TestDevfile) RunTest(testContent TestContent, t *testing.T) {
324
325 if len(testContent.CommandTypes) > 0 {
326 numCommands := GetRandomNumber(1, maxCommands)
327 for i := 0; i < numCommands; i++ {
328 commandIndex := GetRandomNumber(1, len(testContent.CommandTypes))
329 testDevfile.AddCommand(testContent.CommandTypes[commandIndex-1])
330 }
331 }
332
333 if len(testContent.ComponentTypes) > 0 {
334 numComponents := GetRandomNumber(1, maxComponents)
335 for i := 0; i < numComponents; i++ {
336 componentIndex := GetRandomNumber(1, len(testContent.ComponentTypes))
337 testDevfile.AddComponent(testContent.ComponentTypes[componentIndex-1])
338 }
339 }
340
341 if len(testContent.ProjectTypes) > 0 {
342 numProjects := GetRandomNumber(1, maxProjects)
343 for i := 0; i < numProjects; i++ {
344 projectIndex := GetRandomNumber(1, len(testContent.ProjectTypes))
345 testDevfile.AddProject(testContent.ProjectTypes[projectIndex-1])
346 }
347 }
348
349 if len(testContent.StarterProjectTypes) > 0 {
350 numStarterProjects := GetRandomNumber(1, maxStarterProjects)
351 for i := 0; i < numStarterProjects; i++ {
352 starterProjectIndex := GetRandomNumber(1, len(testContent.StarterProjectTypes))
353 testDevfile.AddStarterProject(testContent.StarterProjectTypes[starterProjectIndex-1])
354 }
355 }
356
357 if testContent.AddParent {
358 testDevfile.AddParent()
359 }
360
361 if testContent.AddEvents {
362 testDevfile.AddEvents()
363 }
364
365 if testContent.AddMetaData {
366 testDevfile.AddMetaData()
367 }
368
369 err := testDevfile.Validator.WriteAndValidate(testDevfile)
370 if err != nil {
371 t.Fatalf(LogErrorMessage(fmt.Sprintf("ERROR verifying devfile : %s : %v", testContent.FileName, err)))
372 }
373
374}

Callers 15

RunTestFunction · 0.80
Test_ExecCommandFunction · 0.80
Test_ApplyCommandFunction · 0.80
Test_CompositeCommandFunction · 0.80
Test_MultiCommandFunction · 0.80
Test_ContainerComponentFunction · 0.80
Test_KubernetesComponentFunction · 0.80
Test_OpenshiftComponentFunction · 0.80
Test_VolumeComponentFunction · 0.80
Test_MultiComponentFunction · 0.80
Test_ProjectsFunction · 0.80
Test_StarterProjectsFunction · 0.80

Calls 10

AddCommandMethod · 0.95
AddComponentMethod · 0.95
AddProjectMethod · 0.95
AddStarterProjectMethod · 0.95
AddParentMethod · 0.95
AddEventsMethod · 0.95
AddMetaDataMethod · 0.95
GetRandomNumberFunction · 0.85
LogErrorMessageFunction · 0.85
WriteAndValidateMethod · 0.65

Tested by 15

Test_ExecCommandFunction · 0.64
Test_ApplyCommandFunction · 0.64
Test_CompositeCommandFunction · 0.64
Test_MultiCommandFunction · 0.64
Test_ContainerComponentFunction · 0.64
Test_KubernetesComponentFunction · 0.64
Test_OpenshiftComponentFunction · 0.64
Test_VolumeComponentFunction · 0.64
Test_MultiComponentFunction · 0.64
Test_ProjectsFunction · 0.64
Test_StarterProjectsFunction · 0.64
Test_EventsFunction · 0.64