@@ -881,6 +881,7 @@ func TestParameterValidationEnforcement(t *testing.T) {
881
881
OutputValue string
882
882
Optional bool
883
883
CreateError * regexp.Regexp
884
+ Previous * string
884
885
}
885
886
886
887
rows := make ([]row ,0 )
@@ -898,41 +899,44 @@ func TestParameterValidationEnforcement(t *testing.T) {
898
899
continue // Skip rows with empty names
899
900
}
900
901
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 != "" {
903
907
// Value does not matter if not specified
904
908
require .NoError (t ,err )
905
909
}
906
910
907
911
var rerr * regexp.Regexp
908
- if columns [ 9 ] != "" {
909
- rerr ,err = regexp .Compile (columns [ 9 ] )
912
+ if cerr != "" {
913
+ rerr ,err = regexp .Compile (cerr )
910
914
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 )
912
916
}
913
917
}
914
918
915
919
var options []string
916
- if columns [ 4 ] != "" {
917
- options = strings .Split (columns [ 4 ] ,"," )
920
+ if coptions != "" {
921
+ options = strings .Split (coptions ,"," )
918
922
}
919
923
920
924
var validation * provider.Validation
921
- if columns [ 5 ] != "" {
925
+ if cvalidation != "" {
922
926
switch {
923
- case columns [ 5 ] == provider .ValidationMonotonicIncreasing || columns [ 5 ] == provider .ValidationMonotonicDecreasing :
927
+ case cvalidation == provider .ValidationMonotonicIncreasing || cvalidation == provider .ValidationMonotonicDecreasing :
924
928
validation = & provider.Validation {
925
929
MinDisabled :true ,
926
930
MaxDisabled :true ,
927
- Monotonic :columns [ 5 ] ,
931
+ Monotonic :cvalidation ,
928
932
Error :"monotonicity" ,
929
933
}
930
- case validMinMax .MatchString (columns [ 5 ] ):
934
+ case validMinMax .MatchString (cvalidation ):
931
935
// Min-Max validation should look like:
932
936
//1-10 :: min=1, max=10
933
937
//-10 :: max=10
934
938
//1- :: min=1
935
- parts := strings .Split (columns [ 5 ] ,"-" )
939
+ parts := strings .Split (cvalidation ,"-" )
936
940
min ,_ := strconv .ParseInt (parts [0 ],10 ,64 )
937
941
max ,_ := strconv .ParseInt (parts [1 ],10 ,64 )
938
942
validation = & provider.Validation {
@@ -951,22 +955,30 @@ func TestParameterValidationEnforcement(t *testing.T) {
951
955
Max :0 ,
952
956
MaxDisabled :true ,
953
957
Monotonic :"" ,
954
- Regex :columns [ 5 ] ,
958
+ Regex :cvalidation ,
955
959
Error :"regex error" ,
956
960
}
957
961
}
958
962
}
959
963
964
+ var prev * string
965
+ if cprev != "" {
966
+ prev = ptr (cprev )
967
+ if cprev == `""` {
968
+ prev = ptr ("" )
969
+ }
970
+ }
960
971
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 ,
965
976
Options :options ,
966
977
Validation :validation ,
967
- OutputValue :columns [ 7 ] ,
978
+ OutputValue :coutput ,
968
979
Optional :optional ,
969
980
CreateError :rerr ,
981
+ Previous :prev ,
970
982
})
971
983
}
972
984
@@ -984,6 +996,9 @@ func TestParameterValidationEnforcement(t *testing.T) {
984
996
if row .InputValue != "" {
985
997
t .Setenv (provider .ParameterEnvironmentVariable ("parameter" ),row .InputValue )
986
998
}
999
+ if row .Previous != nil {
1000
+ t .Setenv (provider .ParameterEnvironmentVariablePrevious ("parameter" ),* row .Previous )
1001
+ }
987
1002
988
1003
if row .CreateError != nil && row .OutputValue != "" {
989
1004
t .Errorf ("output value %q should not be set if both errors are set" ,row .OutputValue )