(t *testing.T)
| 235 | } |
| 236 | |
| 237 | func TestValidatePatch(t *testing.T) { |
| 238 | type args struct { |
| 239 | patch v1beta1.ComposedPatch |
| 240 | } |
| 241 | |
| 242 | type want struct { |
| 243 | err *field.Error |
| 244 | } |
| 245 | |
| 246 | cases := map[string]struct { |
| 247 | reason string |
| 248 | args args |
| 249 | want want |
| 250 | }{ |
| 251 | "ValidFromCompositeFieldPath": { |
| 252 | reason: "FromCompositeFieldPath patch with FromFieldPath set should be valid", |
| 253 | args: args{ |
| 254 | patch: v1beta1.ComposedPatch{ |
| 255 | Type: v1beta1.PatchTypeFromCompositeFieldPath, |
| 256 | Patch: v1beta1.Patch{ |
| 257 | FromFieldPath: ptr.To[string]("spec.forProvider.foo"), |
| 258 | }, |
| 259 | }, |
| 260 | }, |
| 261 | }, |
| 262 | "FromCompositeFieldPathWithInvalidTransforms": { |
| 263 | reason: "FromCompositeFieldPath with invalid transforms should return error", |
| 264 | args: args{ |
| 265 | patch: v1beta1.ComposedPatch{ |
| 266 | Type: v1beta1.PatchTypeFromCompositeFieldPath, |
| 267 | Patch: v1beta1.Patch{ |
| 268 | FromFieldPath: ptr.To[string]("spec.forProvider.foo"), |
| 269 | Transforms: []v1beta1.Transform{ |
| 270 | { |
| 271 | Type: v1beta1.TransformTypeMath, |
| 272 | Math: nil, |
| 273 | }, |
| 274 | }, |
| 275 | }, |
| 276 | }, |
| 277 | }, |
| 278 | want: want{ |
| 279 | err: &field.Error{ |
| 280 | Type: field.ErrorTypeRequired, |
| 281 | Field: "transforms[0].math", |
| 282 | }, |
| 283 | }, |
| 284 | }, |
| 285 | "InvalidFromCompositeFieldPathMissingFromFieldPath": { |
| 286 | reason: "Invalid FromCompositeFieldPath missing FromFieldPath should return error", |
| 287 | args: args{ |
| 288 | patch: v1beta1.ComposedPatch{ |
| 289 | Type: v1beta1.PatchTypeFromCompositeFieldPath, |
| 290 | Patch: v1beta1.Patch{ |
| 291 | FromFieldPath: nil, |
| 292 | }, |
| 293 | }, |
| 294 | }, |
nothing calls this directly
no test coverage detected