MCPcopy Create free account
hub / github.com/devspace-sh/devspace / runTestCases

Function runTestCases

pkg/devspace/config/loader/patch/operation_test.go:580–610  ·  view source on GitHub ↗
(testCases map[string]*operationTestCase, t *testing.T)

Source from the content-addressed store, hash-verified

578}
579
580func runTestCases(testCases map[string]*operationTestCase, t *testing.T) {
581 for name, testCase := range testCases {
582 inputNode := loadYamlFromString(testCase.input)
583
584 err := testCase.operation.Perform(inputNode)
585 if err != nil {
586 if testCase.expectedErr != nil && reflect.DeepEqual(err.Error(), testCase.expectedErr.Error()) {
587 continue
588 }
589 t.Errorf("Error %v in case %s", err, name)
590 }
591
592 actual, err := yaml.Marshal(inputNode)
593 if err != nil {
594 t.Errorf("Error %v in case %s", err, name)
595 }
596 actualStr := string(actual)
597
598 expectedNode := loadYamlFromString(testCase.expected)
599 expected, err := yaml.Marshal(expectedNode)
600 if err != nil {
601 t.Errorf("Error %v in case %s", err, name)
602 }
603 expectedStr := string(expected)
604
605 isEqual := reflect.DeepEqual(actualStr, expectedStr)
606 if !isEqual {
607 t.Errorf("TestCase %s\n\nactual:\n\n%s\nbut expected:\n\n%s", name, actualStr, expectedStr)
608 }
609 }
610}

Callers 3

TestAddOperationFunction · 0.85
TestRemoveOperationFunction · 0.85
TestReplaceOperationFunction · 0.85

Calls 4

loadYamlFromStringFunction · 0.85
PerformMethod · 0.80
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected