@@ -1062,6 +1062,27 @@ var _ = Describe("Client", func() {
1062
1062
PIt ("should fail if the GVK cannot be mapped to a Resource" , func () {
1063
1063
1064
1064
})
1065
+
1066
+ It ("should respect passed in update options" , func () {
1067
+ By ("creating a new client" )
1068
+ cl , err := client .New (cfg , client.Options {})
1069
+ Expect (err ).NotTo (HaveOccurred ())
1070
+ Expect (cl ).NotTo (BeNil ())
1071
+
1072
+ By ("initially creating a Deployment" )
1073
+ dep , err := clientset .AppsV1 ().Deployments (ns ).Create (dep )
1074
+ Expect (err ).NotTo (HaveOccurred ())
1075
+
1076
+ By ("patching the Deployment with dry-run" )
1077
+ err = cl .Patch (context .TODO (), dep , client .ConstantPatch (types .MergePatchType , mergePatch ), client .UpdatePatchWith (client .UpdateDryRunAll ()))
1078
+ Expect (err ).NotTo (HaveOccurred ())
1079
+
1080
+ By ("validating patched Deployment doesn't have the new annotation" )
1081
+ actual , err := clientset .AppsV1 ().Deployments (ns ).Get (dep .Name , metav1.GetOptions {})
1082
+ Expect (err ).NotTo (HaveOccurred ())
1083
+ Expect (actual ).NotTo (BeNil ())
1084
+ Expect (actual .Annotations ).NotTo (HaveKey ("foo" ))
1085
+ })
1065
1086
})
1066
1087
Context ("with unstructured objects" , func () {
1067
1088
It ("should patch an existing object from a go struct" , func (done Done ) {
@@ -1142,6 +1163,35 @@ var _ = Describe("Client", func() {
1142
1163
1143
1164
close (done )
1144
1165
})
1166
+
1167
+ It ("should respect passed-in update options" , func () {
1168
+ By ("creating a new client" )
1169
+ cl , err := client .New (cfg , client.Options {})
1170
+ Expect (err ).NotTo (HaveOccurred ())
1171
+ Expect (cl ).NotTo (BeNil ())
1172
+
1173
+ By ("initially creating a Deployment" )
1174
+ dep , err := clientset .AppsV1 ().Deployments (ns ).Create (dep )
1175
+ Expect (err ).NotTo (HaveOccurred ())
1176
+
1177
+ By ("patching the Deployment" )
1178
+ depName := dep .Name
1179
+ u := & unstructured.Unstructured {}
1180
+ scheme .Convert (dep , u , nil )
1181
+ u .SetGroupVersionKind (schema.GroupVersionKind {
1182
+ Group : "apps" ,
1183
+ Kind : "Deployment" ,
1184
+ Version : "v1" ,
1185
+ })
1186
+ err = cl .Patch (context .TODO (), u , client .ConstantPatch (types .MergePatchType , mergePatch ), client .UpdatePatchWith (client .UpdateDryRunAll ()))
1187
+ Expect (err ).NotTo (HaveOccurred ())
1188
+
1189
+ By ("validating patched Deployment does not have the new annotation" )
1190
+ actual , err := clientset .AppsV1 ().Deployments (ns ).Get (depName , metav1.GetOptions {})
1191
+ Expect (err ).NotTo (HaveOccurred ())
1192
+ Expect (actual ).NotTo (BeNil ())
1193
+ Expect (actual .Annotations ).NotTo (HaveKey ("foo" ))
1194
+ })
1145
1195
})
1146
1196
})
1147
1197
0 commit comments