@@ -945,6 +945,15 @@ func TestParameterValidation(t *testing.T) {
945
945
Value :"delta" ,// not in option set
946
946
ExpectError :regexp .MustCompile ("Value must be a valid option" ),
947
947
},
948
+ {
949
+ Name :"NumberNotInOptions" ,
950
+ Parameter : provider.Parameter {
951
+ Type :"number" ,
952
+ Option :opts ("1" ,"2" ,"3" ),
953
+ },
954
+ Value :"0" ,// not in option set
955
+ ExpectError :regexp .MustCompile ("Value must be a valid option" ),
956
+ },
948
957
{
949
958
Name :"NonUniqueOptionNames" ,
950
959
Parameter : provider.Parameter {
@@ -983,6 +992,55 @@ func TestParameterValidation(t *testing.T) {
983
992
Value :"not-a-number" ,
984
993
ExpectError :regexp .MustCompile ("Parameter value is not of type\" number\" " ),
985
994
},
995
+ {
996
+ Name :"NotListStringDefault" ,
997
+ Parameter : provider.Parameter {
998
+ Type :"list(string)" ,
999
+ Default :"not-a-list" ,
1000
+ },
1001
+ ExpectError :regexp .MustCompile ("not a valid list of strings" ),
1002
+ },
1003
+ {
1004
+ Name :"NotListStringDefault" ,
1005
+ Parameter : provider.Parameter {
1006
+ Type :"list(string)" ,
1007
+ },
1008
+ Value :"not-a-list" ,
1009
+ ExpectError :regexp .MustCompile ("not a valid list of strings" ),
1010
+ },
1011
+ {
1012
+ Name :"DefaultListStringNotInOptions" ,
1013
+ Parameter : provider.Parameter {
1014
+ Type :"list(string)" ,
1015
+ Default :`["red", "yellow", "black"]` ,
1016
+ Option :opts ("red" ,"blue" ,"green" ),
1017
+ FormType :provider .ParameterFormTypeMultiSelect ,
1018
+ },
1019
+ ExpectError :regexp .MustCompile ("is not a valid option, values\" yellow, black\" are missing from the options" ),
1020
+ },
1021
+ {
1022
+ Name :"ListStringNotInOptions" ,
1023
+ Parameter : provider.Parameter {
1024
+ Type :"list(string)" ,
1025
+ Default :`["red"]` ,
1026
+ Option :opts ("red" ,"blue" ,"green" ),
1027
+ FormType :provider .ParameterFormTypeMultiSelect ,
1028
+ },
1029
+ Value :`["red", "yellow", "black"]` ,
1030
+ ExpectError :regexp .MustCompile ("is not a valid option, values\" yellow, black\" are missing from the options" ),
1031
+ },
1032
+ {
1033
+ Name :"InvalidMiniumum" ,
1034
+ Parameter : provider.Parameter {
1035
+ Type :"number" ,
1036
+ Default :"5" ,
1037
+ Validation : []provider.Validation {{
1038
+ Min :10 ,
1039
+ Error :"must be greater than 10" ,
1040
+ }},
1041
+ },
1042
+ ExpectError :regexp .MustCompile ("must be greater than 10" ),
1043
+ },
986
1044
} {
987
1045
tc := tc
988
1046
t .Run (tc .Name ,func (t * testing.T ) {