MCPcopy Create free account
hub / github.com/crossplane-contrib/function-patch-and-transform / TestValidateCombine

Function TestValidateCombine

validate_test.go:382–505  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

380}
381
382func TestValidateCombine(t *testing.T) {
383 type args struct {
384 combine v1beta1.Combine
385 }
386 type want struct {
387 err *field.Error
388 }
389
390 cases := map[string]struct {
391 reason string
392 args args
393 want want
394 }{
395 "MissingStrategy": {
396 reason: "A combine with no strategy is invalid",
397 args: args{
398 combine: v1beta1.Combine{},
399 },
400 want: want{
401 err: &field.Error{
402 Type: field.ErrorTypeRequired,
403 Field: "strategy",
404 },
405 },
406 },
407 "InvalidStrategy": {
408 reason: "A combine with an unknown strategy is invalid",
409 args: args{
410 combine: v1beta1.Combine{
411 Strategy: "Smoosh",
412 },
413 },
414 want: want{
415 err: &field.Error{
416 Type: field.ErrorTypeInvalid,
417 Field: "strategy",
418 },
419 },
420 },
421 "ValidStringCombine": {
422 reason: "A string combine with variables and a format string should be valid",
423 args: args{
424 combine: v1beta1.Combine{
425 Strategy: v1beta1.CombineStrategyString,
426 Variables: []v1beta1.CombineVariable{
427 {FromFieldPath: "a"},
428 {FromFieldPath: "b"},
429 },
430 String: &v1beta1.StringCombine{
431 Format: "%s-%s",
432 },
433 },
434 },
435 want: want{
436 err: nil,
437 },
438 },
439 "MissingVariables": {

Callers

nothing calls this directly

Calls 2

ValidateCombineFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected