Skip to content

Commit

Permalink
feat: allow rollback ignore not found
Browse files Browse the repository at this point in the history
  • Loading branch information
l-qing committed Oct 31, 2022
1 parent e8f46ed commit 979ddbe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions testing/framework/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func MustRollback(testCtx *TestContext, obj client.Object, opts ...client.Delete
Expect(obj).NotTo(BeNil())

err := testCtx.Client.Delete(testCtx.Context, obj, opts...)
err = client.IgnoreNotFound(err)
Expect(err).To(Succeed())

WaitRollback(testCtx, obj)
Expand Down
18 changes: 18 additions & 0 deletions testing/framework/condition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,22 @@ var _ = Describe("TestCondition", func() {
})
})

Context("rollback but resouce not found", func() {
cm := NewTestConfigMap("aa", "default", nil)

When("rollback action", func() {
It("should rollback successfully", func() {
key := types.NamespacedName{
Namespace: cm.Namespace,
Name: cm.Name,
}
newCm := &corev1.ConfigMap{}
err := testCtx.Client.Get(testCtx.Context, key, newCm)
Expect(errors.IsNotFound(err)).To(BeTrue())

MustRollback(testCtx, cm)
})
})
})

})

0 comments on commit 979ddbe

Please sign in to comment.