@@ -66,6 +66,10 @@ var _ = Describe("Operator", func() {
66
66
// 10. Ensure the reference to sa-b is eventually removed from o's status.components.refs field
67
67
// 11. Delete ns-a
68
68
// 12. Ensure the reference to ns-a is eventually removed from o's status.components.refs field
69
+ // 13. Delete o
70
+ // 14. Ensure o is re-created
71
+ // 15. Delete ns-b and o
72
+ // 16. Ensure o is not re-created
69
73
It ("should surface components in its status" , func () {
70
74
o := & operatorsv1.Operator {}
71
75
o .SetName (genName ("o-" ))
@@ -196,6 +200,39 @@ var _ = Describe("Operator", func() {
196
200
// Ensure the reference to ns-a is eventually removed from o's status.components.refs field
197
201
By ("removing a component's reference when it no longer exists" )
198
202
componentRefEventuallyExists (w , false , getReference (scheme , nsA ))
203
+
204
+ // Delete o
205
+ Eventually (func () error {
206
+ err := client .Delete (clientCtx , o )
207
+ if err != nil && ! apierrors .IsNotFound (err ) {
208
+ return err
209
+ }
210
+ return nil
211
+ }).Should (Succeed ())
212
+
213
+ // Ensure that o is eventually recreated (because some of its components still exist).
214
+ By ("recreating the Operator when any components still exist" )
215
+ Eventually (func () error {
216
+ return client .Get (clientCtx , types.NamespacedName {Name : o .GetName ()}, o )
217
+ }).Should (Succeed ())
218
+
219
+ // Delete ns-b and o
220
+ Eventually (func () error {
221
+ if err := client .Delete (clientCtx , nsB ); err != nil && ! apierrors .IsNotFound (err ) {
222
+ return err
223
+ }
224
+ if err := client .Delete (clientCtx , o ); err != nil && ! apierrors .IsNotFound (err ) {
225
+ return err
226
+ }
227
+ return nil
228
+ }).Should (Succeed ())
229
+
230
+ // Ensure that o is consistently not found
231
+ By ("verifying the Operator is permanently deleted if it has no components" )
232
+ Consistently (func () bool {
233
+ err := client .Get (clientCtx , types.NamespacedName {Name : o .GetName ()}, o )
234
+ return apierrors .IsNotFound (err )
235
+ }).Should (BeTrue ())
199
236
})
200
237
201
238
Context ("when a subscription to a package exists" , func () {
0 commit comments