diff --git a/pkg/test/expression_integration_test.go b/pkg/test/expression_integration_test.go index 95b0d8c1..1caca12d 100644 --- a/pkg/test/expression_integration_test.go +++ b/pkg/test/expression_integration_test.go @@ -149,26 +149,22 @@ func TestAssertExpressions(t *testing.T) { files, err := os.ReadDir(dirName) assert.NoError(t, err) - for i := 0; i < len(files)-1; i++ { - fName := fmt.Sprintf("%s/%s", dirName, files[i].Name()) - step := buildTestStep(t, testenv) - assert.NoError(t, step.LoadYAML(fName)) - assert.NoError(t, errors.Join(errors.Join(step.Run(t, testNamespace)...))) - } - step := buildTestStep(t, testenv) + for _, file := range files { + fName := fmt.Sprintf("%s/%s", dirName, file.Name()) + if err = step.LoadYAML(fName); err != nil { + break + } + } - fName := fmt.Sprintf("%s/%s", dirName, files[len(files)-1].Name()) - - err = step.LoadYAML(fName) if !tc.expectLoadFailure { assert.NoError(t, err) - } else { + } else if tc.expectLoadFailure { assert.ErrorContains(t, err, tc.expectedErrorMessage) return } - err = errors.Join(step.Run(t, testNamespace)...) + err = errors.Join(errors.Join(step.Run(t, testNamespace)...)) if !tc.expectRunFailure { assert.NoError(t, err) } else { diff --git a/pkg/test/step.go b/pkg/test/step.go index 52b072e5..7fb75c78 100644 --- a/pkg/test/step.go +++ b/pkg/test/step.go @@ -194,6 +194,7 @@ func (s *Step) Create(test *testing.T, namespace string) []error { errors := []error{} + fmt.Println("HEREA1", len(s.Apply)) for _, obj := range s.Apply { _, _, err := kubernetes.Namespaced(dClient, obj, namespace) if err != nil { @@ -225,7 +226,10 @@ func (s *Step) Create(test *testing.T, namespace string) []error { } s.Logger.Log(kubernetes.ResourceID(obj), action) } + + fmt.Println("HEREA", obj.GetNamespace(), obj.GetName()) } + fmt.Println("HEREB", errors) return errors } @@ -429,6 +433,7 @@ func (s *Step) CheckAssertExpressions(namespace string) []error { } namespacedName, referencedResource := resourceRef.BuildResourceReference() if err := client.Get(context.TODO(), namespacedName, referencedResource); err != nil { + fmt.Println("HEREB", err) return []error{fmt.Errorf("failed to get referenced resource '%v': %w", namespacedName, err)} } @@ -679,6 +684,8 @@ func (s *Step) populateObjectsByFileName(fileName string, objects []client.Objec return fmt.Errorf("%s does not match file name regexp: %s", fileName, testStepRegex.String()) } + fmt.Println("HEREC", strings.ToLower(matches[1])) + switch fname := strings.ToLower(matches[1]); fname { case "assert": s.Asserts = append(s.Asserts, objects...) diff --git a/pkg/test/step_integration_test_data/assert_expressions/check_expression_for_ephemeral_namespace/01-assert.yaml b/pkg/test/step_integration_test_data/assert_expressions/check_expression_for_ephemeral_namespace/00-assert.yaml similarity index 100% rename from pkg/test/step_integration_test_data/assert_expressions/check_expression_for_ephemeral_namespace/01-assert.yaml rename to pkg/test/step_integration_test_data/assert_expressions/check_expression_for_ephemeral_namespace/00-assert.yaml