@@ -881,6 +881,7 @@ func TestParameterValidationEnforcement(t *testing.T) {
881881 OutputValue string
882882 Optional bool
883883 CreateError * regexp.Regexp
884+ Previous * string
884885 }
885886
886887 rows := make ([]row , 0 )
@@ -898,41 +899,44 @@ func TestParameterValidationEnforcement(t *testing.T) {
898899 continue // Skip rows with empty names
899900 }
900901
901- optional , err := strconv .ParseBool (columns [8 ])
902- if columns [8 ] != "" {
902+ cname , ctype , cprev , cinput , cdefault , coptions , cvalidation , _ , coutput , coptional , cerr :=
903+ columns [0 ], columns [1 ], columns [2 ], columns [3 ], columns [4 ], columns [5 ], columns [6 ], columns [7 ], columns [8 ], columns [9 ], columns [10 ]
904+
905+ optional , err := strconv .ParseBool (coptional )
906+ if coptional != "" {
903907 // Value does not matter if not specified
904908 require .NoError (t , err )
905909 }
906910
907911 var rerr * regexp.Regexp
908- if columns [ 9 ] != "" {
909- rerr , err = regexp .Compile (columns [ 9 ] )
912+ if cerr != "" {
913+ rerr , err = regexp .Compile (cerr )
910914 if err != nil {
911- t .Fatalf ("failed to parse error column %q: %v" , columns [ 9 ] , err )
915+ t .Fatalf ("failed to parse error column %q: %v" , cerr , err )
912916 }
913917 }
914918
915919 var options []string
916- if columns [ 4 ] != "" {
917- options = strings .Split (columns [ 4 ] , "," )
920+ if coptions != "" {
921+ options = strings .Split (coptions , "," )
918922 }
919923
920924 var validation * provider.Validation
921- if columns [ 5 ] != "" {
925+ if cvalidation != "" {
922926 switch {
923- case columns [ 5 ] == provider .ValidationMonotonicIncreasing || columns [ 5 ] == provider .ValidationMonotonicDecreasing :
927+ case cvalidation == provider .ValidationMonotonicIncreasing || cvalidation == provider .ValidationMonotonicDecreasing :
924928 validation = & provider.Validation {
925929 MinDisabled : true ,
926930 MaxDisabled : true ,
927- Monotonic : columns [ 5 ] ,
931+ Monotonic : cvalidation ,
928932 Error : "monotonicity" ,
929933 }
930- case validMinMax .MatchString (columns [ 5 ] ):
934+ case validMinMax .MatchString (cvalidation ):
931935 // Min-Max validation should look like:
932936 // 1-10 :: min=1, max=10
933937 // -10 :: max=10
934938 // 1- :: min=1
935- parts := strings .Split (columns [ 5 ] , "-" )
939+ parts := strings .Split (cvalidation , "-" )
936940 min , _ := strconv .ParseInt (parts [0 ], 10 , 64 )
937941 max , _ := strconv .ParseInt (parts [1 ], 10 , 64 )
938942 validation = & provider.Validation {
@@ -951,22 +955,30 @@ func TestParameterValidationEnforcement(t *testing.T) {
951955 Max : 0 ,
952956 MaxDisabled : true ,
953957 Monotonic : "" ,
954- Regex : columns [ 5 ] ,
958+ Regex : cvalidation ,
955959 Error : "regex error" ,
956960 }
957961 }
958962 }
959963
964+ var prev * string
965+ if cprev != "" {
966+ prev = ptr (cprev )
967+ if cprev == `""` {
968+ prev = ptr ("" )
969+ }
970+ }
960971 rows = append (rows , row {
961- Name : columns [ 0 ] ,
962- Types : strings .Split (columns [ 1 ] , "," ),
963- InputValue : columns [ 2 ] ,
964- Default : columns [ 3 ] ,
972+ Name : cname ,
973+ Types : strings .Split (ctype , "," ),
974+ InputValue : cinput ,
975+ Default : cdefault ,
965976 Options : options ,
966977 Validation : validation ,
967- OutputValue : columns [ 7 ] ,
978+ OutputValue : coutput ,
968979 Optional : optional ,
969980 CreateError : rerr ,
981+ Previous : prev ,
970982 })
971983 }
972984
@@ -984,6 +996,9 @@ func TestParameterValidationEnforcement(t *testing.T) {
984996 if row .InputValue != "" {
985997 t .Setenv (provider .ParameterEnvironmentVariable ("parameter" ), row .InputValue )
986998 }
999+ if row .Previous != nil {
1000+ t .Setenv (provider .ParameterEnvironmentVariablePrevious ("parameter" ), * row .Previous )
1001+ }
9871002
9881003 if row .CreateError != nil && row .OutputValue != "" {
9891004 t .Errorf ("output value %q should not be set if both errors are set" , row .OutputValue )
0 commit comments