Skip to content

Commit 14ee3f7

Browse files
committed
Ensure installed resources are only delete if an error is NOT expected
1 parent aba710a commit 14ee3f7

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

tests/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ uninstall-ngf: ## Uninstall NGF on configured kind cluster
192192
.PHONY: test-cel-validation
193193
test-cel-validation:
194194
-make install-crds || true;
195-
-make install-gateway-crds || true;
196195
@if [ -z "$(CEL_TEST_TARGET)" ]; then \
197196
echo "Running all tests in ./cel"; \
198197
go test -v ./cel; \

tests/cel/common.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,14 @@ func validateCrd(t *testing.T, wantErrors []string, crd client.Object, k8sClient
100100
defer cancel()
101101
err := k8sClient.Create(ctx, crd)
102102

103-
// Clean up after test
104-
defer func() {
105-
deleteErr = k8sClient.Delete(ctx, crd)
106-
}()
107-
g.Expect(deleteErr).ToNot(HaveOccurred())
108-
109103
// Check for expected errors
110104
if len(wantErrors) == 0 {
111105
g.Expect(err).ToNot(HaveOccurred())
106+
// Clean up after test
107+
defer func() {
108+
deleteErr = k8sClient.Delete(ctx, crd)
109+
g.Expect(deleteErr).ToNot(HaveOccurred())
110+
}()
112111
} else {
113112
g.Expect(err).To(HaveOccurred())
114113
for _, wantError := range wantErrors {

0 commit comments

Comments
 (0)