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

Function TestValidateTransform

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

Source from the content-addressed store, hash-verified

505}
506
507func TestValidateTransform(t *testing.T) {
508 type args struct {
509 transform v1beta1.Transform
510 }
511 type want struct {
512 err *field.Error
513 }
514
515 cases := map[string]struct {
516 reason string
517 args args
518 want want
519 }{
520 "ValidMathMultiply": {
521 reason: "Math transform with MathTransform Multiply set should be valid",
522 args: args{
523 transform: v1beta1.Transform{
524 Type: v1beta1.TransformTypeMath,
525 Math: &v1beta1.MathTransform{
526 Type: v1beta1.MathTransformTypeMultiply,
527 Multiply: ptr.To[int64](2),
528 },
529 },
530 },
531 },
532 "ValidMathClampMin": {
533 reason: "Math transform with valid MathTransform ClampMin set should be valid",
534 args: args{
535 transform: v1beta1.Transform{
536 Type: v1beta1.TransformTypeMath,
537 Math: &v1beta1.MathTransform{
538 Type: v1beta1.MathTransformTypeClampMin,
539 ClampMin: ptr.To[int64](10),
540 },
541 },
542 },
543 },
544 "InvalidMathWrongSpec": {
545 reason: "Math transform with invalid MathTransform set should be invalid",
546 args: args{
547 transform: v1beta1.Transform{
548 Type: v1beta1.TransformTypeMath,
549 Math: &v1beta1.MathTransform{
550 Type: v1beta1.MathTransformTypeMultiply,
551 ClampMin: ptr.To[int64](10),
552 },
553 },
554 },
555 want: want{
556 &field.Error{
557 Type: field.ErrorTypeRequired,
558 Field: "math.multiply",
559 },
560 },
561 },
562 "InvalidMathNotDefinedAtAll": {
563 reason: "Math transform with no MathTransform set should be invalid",
564 args: args{

Callers

nothing calls this directly

Calls 3

TransformIOTypeTypeAlias · 0.92
ValidateTransformFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected