Skip to content

Commit

Permalink
fix: controller test 201 and fix test clean-up
Browse files Browse the repository at this point in the history
```
❯ go test ./controllers -parallel=1 -count=3 -test.run="Test_000201"
ok      github.com/weaveworks/tf-controller/controllers 99.224s
```

For the cleanup:
Sadly `resource.GetObjectKind().GroupVersionKind().Kind` is an empty
string, so it didn't work at all.

Fixes #947

References:
* #947

Signed-off-by: Balazs Nadasdi <balazs@weave.works>
  • Loading branch information
yitsushi committed Sep 12, 2023
1 parent b8cace0 commit 99da532
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion controllers/cleaner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func waitResourceToBeDelete(g gomega.Gomega, resource client.Object) {
return k8sClient.Get(ctx, key, resource)
}, cleanupTimeoutSeconds, interval).ShouldNot(gomega.Succeed())

if resource.GetObjectKind().GroupVersionKind().Kind == infrav1.TerraformKind {
if _, ok := resource.(*infrav1.Terraform); ok {
waitDefaultSecretsToBeDeletedForTerraform(g, resource)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build flaky

package controllers

import (
Expand Down Expand Up @@ -44,7 +42,7 @@ func Test_000201_auto_approve_with_disabled_drift_detection(t *testing.T) {
},
}
g.Expect(k8sClient.Create(ctx, &testRepo)).Should(Succeed())
defer func() { g.Expect(k8sClient.Delete(ctx, &testRepo)).Should(Succeed()) }()
defer waitResourceToBeDelete(g, &testRepo)

By("setting the git repo status object, the URL, and the correct checksum")
testRepo.Status = sourcev1.GitRepositoryStatus{
Expand Down Expand Up @@ -101,7 +99,7 @@ func Test_000201_auto_approve_with_disabled_drift_detection(t *testing.T) {
},
}
g.Expect(k8sClient.Create(ctx, &helloWorldTF)).Should(Succeed())
defer func() { g.Expect(k8sClient.Delete(ctx, &helloWorldTF)).Should(Succeed()) }()
defer waitResourceToBeDelete(g, &helloWorldTF)

By("checking that the hello world TF gets created")
helloWorldTFKey := types.NamespacedName{Namespace: "flux-system", Name: terraformName}
Expand Down

0 comments on commit 99da532

Please sign in to comment.