Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6ee8b80

Browse files
committed
add more validation tests
1 parent9bb9a1f commit6ee8b80

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

‎provider/parameter_test.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,15 @@ func TestParameterValidation(t *testing.T) {
945945
Value:"delta",// not in option set
946946
ExpectError:regexp.MustCompile("Value must be a valid option"),
947947
},
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+
},
948957
{
949958
Name:"NonUniqueOptionNames",
950959
Parameter: provider.Parameter{
@@ -983,6 +992,55 @@ func TestParameterValidation(t *testing.T) {
983992
Value:"not-a-number",
984993
ExpectError:regexp.MustCompile("Parameter value is not of type\"number\""),
985994
},
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+
},
9861044
} {
9871045
tc:=tc
9881046
t.Run(tc.Name,func(t*testing.T) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp