Skip to content

Commit

Permalink
Fix panic in unit test
Browse files Browse the repository at this point in the history
o.MatchError will panic if a k8s NotFound error is returned. This is
fixed by checking that a NotFound error is raised separate from a gomega
match.
  • Loading branch information
adambkaplan committed Dec 1, 2021
1 parent d308182 commit 8dd6d1b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion controllers/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ var _ = g.Describe("Reconcile default ShipwrightBuild installation", func() {

err = k8sClient.Delete(ctx, build, &client.DeleteOptions{})
// the delete e2e's can delete this object before this AfterEach runs
o.Expect(err).To(o.BeNil(), o.MatchError(metav1.StatusReasonNotFound))
if errors.IsNotFound(err) {
return
}
o.Expect(err).NotTo(o.HaveOccurred())

g.By("waiting for ShipwrightBuild instance to be completely removed")
test.EventuallyRemoved(ctx, k8sClient, build)
Expand Down

0 comments on commit 8dd6d1b

Please sign in to comment.