@@ -449,6 +449,17 @@ var _ = Describe("Controllerutil", func() {
449
449
specr = deploymentSpecr (deploy , deplSpec )
450
450
})
451
451
452
+ assertLocalDeployWasUpdated := func (fetched * appsv1.Deployment ) {
453
+ By ("local deploy object was updated during patch & has same spec, status, resource version as fetched" )
454
+ if fetched == nil {
455
+ fetched = & appsv1.Deployment {}
456
+ ExpectWithOffset (1 , c .Get (context .TODO (), deplKey , fetched )).To (Succeed ())
457
+ }
458
+ ExpectWithOffset (1 , fetched .ResourceVersion ).To (Equal (deploy .ResourceVersion ))
459
+ ExpectWithOffset (1 , fetched .Spec ).To (BeEquivalentTo (deploy .Spec ))
460
+ ExpectWithOffset (1 , fetched .Status ).To (BeEquivalentTo (deploy .Status ))
461
+ }
462
+
452
463
It ("creates a new object if one doesn't exists" , func () {
453
464
op , err := controllerutil .CreateOrPatch (context .TODO (), c , deploy , specr )
454
465
@@ -485,6 +496,7 @@ var _ = Describe("Controllerutil", func() {
485
496
fetched := & appsv1.Deployment {}
486
497
Expect (c .Get (context .TODO (), deplKey , fetched )).To (Succeed ())
487
498
Expect (* fetched .Spec .Replicas ).To (Equal (scale ))
499
+ assertLocalDeployWasUpdated (fetched )
488
500
})
489
501
490
502
It ("patches only changed objects" , func () {
@@ -499,6 +511,8 @@ var _ = Describe("Controllerutil", func() {
499
511
500
512
By ("returning OperationResultNone" )
501
513
Expect (op ).To (BeEquivalentTo (controllerutil .OperationResultNone ))
514
+
515
+ assertLocalDeployWasUpdated (nil )
502
516
})
503
517
504
518
It ("patches only changed status" , func () {
@@ -517,6 +531,8 @@ var _ = Describe("Controllerutil", func() {
517
531
518
532
By ("returning OperationResultUpdatedStatusOnly" )
519
533
Expect (op ).To (BeEquivalentTo (controllerutil .OperationResultUpdatedStatusOnly ))
534
+
535
+ assertLocalDeployWasUpdated (nil )
520
536
})
521
537
522
538
It ("patches resource and status" , func () {
@@ -539,6 +555,8 @@ var _ = Describe("Controllerutil", func() {
539
555
540
556
By ("returning OperationResultUpdatedStatus" )
541
557
Expect (op ).To (BeEquivalentTo (controllerutil .OperationResultUpdatedStatus ))
558
+
559
+ assertLocalDeployWasUpdated (nil )
542
560
})
543
561
544
562
It ("errors when MutateFn changes object name on creation" , func () {
0 commit comments