@@ -550,6 +550,38 @@ var _ = Describe("Fake client", func() {
550
550
Expect (obj .ObjectMeta .ResourceVersion ).To (Equal ("1000" ))
551
551
})
552
552
553
+ It ("should allow patch with non-set ResourceVersion for a resource that doesn't allow unconditional updates" , func () {
554
+ schemeBuilder := & scheme.Builder {GroupVersion : schema.GroupVersion {Group : "test" , Version : "v1" }}
555
+ schemeBuilder .Register (& WithPointerMeta {}, & WithPointerMetaList {})
556
+
557
+ scheme := runtime .NewScheme ()
558
+ Expect (schemeBuilder .AddToScheme (scheme )).NotTo (HaveOccurred ())
559
+
560
+ cl := NewClientBuilder ().WithScheme (scheme ).Build ()
561
+ original := & WithPointerMeta {
562
+ ObjectMeta : & metav1.ObjectMeta {
563
+ Name : "obj" ,
564
+ Namespace : "ns2" ,
565
+ }}
566
+
567
+ err := cl .Create (context .Background (), original )
568
+ Expect (err ).ToNot (HaveOccurred ())
569
+
570
+ newObj := & WithPointerMeta {
571
+ ObjectMeta : & metav1.ObjectMeta {
572
+ Name : original .Name ,
573
+ Namespace : original .Namespace ,
574
+ Annotations : map [string ]string {
575
+ "foo" : "bar" ,
576
+ },
577
+ }}
578
+ Expect (cl .Patch (context .Background (), newObj , client .MergeFrom (original ))).To (Succeed ())
579
+
580
+ patched := & WithPointerMeta {}
581
+ Expect (cl .Get (context .Background (), client .ObjectKeyFromObject (original ), patched )).To (Succeed ())
582
+ Expect (patched .Annotations ).To (Equal (map [string ]string {"foo" : "bar" }))
583
+ })
584
+
553
585
It ("should reject updates with non-set ResourceVersion for a resource that doesn't allow unconditional updates" , func () {
554
586
By ("Creating a new binding" )
555
587
binding := & corev1.Binding {
0 commit comments