Skip to content

Commit 4e7da25

Browse files
authored
test: add more validation test cases (#388)
Some of these cases you would expect it to be an error, but the validation passes
1 parent ac2f9bf commit 4e7da25

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

provider/parameter_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,9 @@ func TestParameterValidationEnforcement(t *testing.T) {
704704
// - [NumIns/DefInv] So the default can be invalid if an input value is valid.
705705
// The value is therefore not really optional, but it is marked as such.
706706
// - [NumInsNotOptsVal | NumsInsNotOpts] values do not need to be in the option set?
707+
// - [NumInsNotNum] number params do not require the value to be a number
708+
// - [LStrInsNotList] list(string) do not require the value to be a list(string)
709+
// - Same with [MulInsNotListOpts]
707710
table, err := os.ReadFile("testdata/parameter_table.md")
708711
require.NoError(t, err)
709712

provider/testdata/parameter_table.md

+9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
|----------------------|---------------|-----------|---------|-------------------|------------|----|--------|----------|--------------|
33
| | Empty Vals | | | | | | | | |
44
| Empty | string,number | | | | | | "" | false | |
5+
| EmptyDupeOps | string,number | | | 1,1,1 | | | | | unique |
56
| EmptyList | list(string) | | | | | | "" | false | |
7+
| EmptyListDupeOpts | list(string) | | | ["a"],["a"] | | | | | unique |
68
| EmptyMulti | tag-select | | | | | | "" | false | |
79
| EmptyOpts | string,number | | | 1,2,3 | | | "" | false | |
810
| EmptyRegex | string | | | | world | | | | regex error |
@@ -18,6 +20,8 @@
1820
| NumDefOpts | number | | 5 | 1,3,5,7 | 2-6 | | 5 | true | |
1921
| NumDefNotOpts | number | | 5 | 1,3,7,9 | 2-6 | | | | valid option |
2022
| NumDefInvOpt | number | | 5 | 1,3,5,7 | 6-10 | | | | 6 < 5 < 10 |
23+
| NumDefNotNum | number | | a | | | | | | a number |
24+
| NumDefOptsNotNum | number | | 1 | 1,a,2 | | | | | a number |
2125
| | | | | | | | | | |
2226
| StrDef | string | | hello | | | | hello | true | |
2327
| StrDefInv | string | | hello | | world | | | | regex error |
@@ -36,6 +40,8 @@
3640
| | | | | | | | | | |
3741
| | Input Vals | | | | | | | | |
3842
| NumIns | number | 3 | | | | | 3 | false | |
43+
| NumInsNotNum | number | a | | | | | a | false | |
44+
| NumInsNotNumInv | number | a | | | 1-3 | | | | 1 < a < 3 |
3945
| NumInsDef | number | 3 | 5 | | | | 3 | true | |
4046
| NumIns/DefInv | number | 3 | 5 | | 1-3 | | 3 | true | |
4147
| NumIns=DefInv | number | 5 | 5 | | 1-3 | | | | 1 < 5 < 3 |
@@ -46,6 +52,7 @@
4652
| NumInsNotOpts/NoDef | number | 3 | | 1,2,4,5 | | | 3 | false | |
4753
| | | | | | | | | | |
4854
| StrIns | string | c | | | | | c | false | |
55+
| StrInsDupeOpts | string | c | | a,b,c,c | | | | | unique |
4956
| StrInsDef | string | c | e | | | | c | true | |
5057
| StrIns/DefInv | string | c | e | | [a-c] | | c | true | |
5158
| StrIns=DefInv | string | e | e | | [a-c] | | | | regex error |
@@ -58,13 +65,15 @@
5865
| | | | | | | | | | |
5966
| | list(string) | | | | | | | | |
6067
| LStrIns | list(string) | ["c"] | | | | | ["c"] | false | |
68+
| LStrInsNotList | list(string) | c | | | | | c | false | |
6169
| LStrInsDef | list(string) | ["c"] | ["e"] | | | | ["c"] | true | |
6270
| LStrIns/DefInv | list(string) | ["c"] | ["e"] | | [a-c] | | | | regex cannot |
6371
| LStrInsOpts | list(string) | ["c"] | ["e"] | ["c"],["d"],["e"] | | | ["c"] | true | |
6472
| LStrInsNotOpts | list(string) | ["c"] | ["e"] | ["d"],["e"] | | | ["c"] | true | |
6573
| LStrInsNotOpts/NoDef | list(string) | ["c"] | | ["d"],["e"] | | | ["c"] | false | |
6674
| | | | | | | | | | |
6775
| MulInsOpts | multi-select | ["c"] | ["e"] | c,d,e | | | ["c"] | true | |
76+
| MulInsNotListOpts | multi-select | c | ["e"] | c,d,e | | | c | true | |
6877
| MulInsNotOpts | multi-select | ["c"] | ["e"] | d,e | | | ["c"] | true | |
6978
| MulInsNotOpts/NoDef | multi-select | ["c"] | | d,e | | | ["c"] | false | |
7079
| MulInsInvOpts | multi-select | ["c"] | ["e"] | c,d,e | [a-c] | | | | regex cannot |

0 commit comments

Comments
 (0)