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

test: add more validation test cases#388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 1 commit intomainfromstevenmasley/more_valid_cases
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletionsprovider/parameter_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -704,6 +704,9 @@ func TestParameterValidationEnforcement(t *testing.T) {
//- [NumIns/DefInv] So the default can be invalid if an input value is valid.
// The value is therefore not really optional, but it is marked as such.
// - [NumInsNotOptsVal | NumsInsNotOpts] values do not need to be in the option set?
// - [NumInsNotNum] number params do not require the value to be a number
// - [LStrInsNotList] list(string) do not require the value to be a list(string)
//- Same with [MulInsNotListOpts]
table, err := os.ReadFile("testdata/parameter_table.md")
require.NoError(t, err)

Expand Down
9 changes: 9 additions & 0 deletionsprovider/testdata/parameter_table.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,9 @@
|----------------------|---------------|-----------|---------|-------------------|------------|----|--------|----------|--------------|
| | Empty Vals | | | | | | | | |
| Empty | string,number | | | | | | "" | false | |
| EmptyDupeOps | string,number | | | 1,1,1 | | | | | unique |
| EmptyList | list(string) | | | | | | "" | false | |
| EmptyListDupeOpts | list(string) | | | ["a"],["a"] | | | | | unique |
| EmptyMulti | tag-select | | | | | | "" | false | |
| EmptyOpts | string,number | | | 1,2,3 | | | "" | false | |
| EmptyRegex | string | | | | world | | | | regex error |
Expand All@@ -18,6 +20,8 @@
| NumDefOpts | number | | 5 | 1,3,5,7 | 2-6 | | 5 | true | |
| NumDefNotOpts | number | | 5 | 1,3,7,9 | 2-6 | | | | valid option |
| NumDefInvOpt | number | | 5 | 1,3,5,7 | 6-10 | | | | 6 < 5 < 10 |
| NumDefNotNum | number | | a | | | | | | a number |
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

So you can pass in "a" for a "number" param... interesting.

You can see it for yourself:

data"coder_parameter""region" {name="region"type="number"order=1}
$ CODER_PARAMETER_c697d2981bf416569a16cfbcdec1542b5398f3cc77d2b905819aa99c46ecf6f6=nan terraform apply&& terraform show# data.coder_parameter.region:data"coder_parameter""region" {    description ="Which region would you like to deploy to?"    ephemeral   =false    form_type   ="input"    id          ="2aec6abf-883a-4618-98c6-6e262e2bfd9b"    mutable     =false    name        ="region"    optional    =false    order       = 1    styling     = jsonencode({})type        ="number"    value       ="nan"}

| NumDefOptsNotNum | number | | 1 | 1,a,2 | | | | | a number |
| | | | | | | | | | |
| StrDef | string | | hello | | | | hello | true | |
| StrDefInv | string | | hello | | world | | | | regex error |
Expand All@@ -36,6 +40,8 @@
| | | | | | | | | | |
| | Input Vals | | | | | | | | |
| NumIns | number | 3 | | | | | 3 | false | |
| NumInsNotNum | number | a | | | | | a | false | |
| NumInsNotNumInv | number | a | | | 1-3 | | | | 1 < a < 3 |
| NumInsDef | number | 3 | 5 | | | | 3 | true | |
| NumIns/DefInv | number | 3 | 5 | | 1-3 | | 3 | true | |
| NumIns=DefInv | number | 5 | 5 | | 1-3 | | | | 1 < 5 < 3 |
Expand All@@ -46,6 +52,7 @@
| NumInsNotOpts/NoDef | number | 3 | | 1,2,4,5 | | | 3 | false | |
| | | | | | | | | | |
| StrIns | string | c | | | | | c | false | |
| StrInsDupeOpts | string | c | | a,b,c,c | | | | | unique |
| StrInsDef | string | c | e | | | | c | true | |
| StrIns/DefInv | string | c | e | | [a-c] | | c | true | |
| StrIns=DefInv | string | e | e | | [a-c] | | | | regex error |
Expand All@@ -58,13 +65,15 @@
| | | | | | | | | | |
| | list(string) | | | | | | | | |
| LStrIns | list(string) | ["c"] | | | | | ["c"] | false | |
| LStrInsNotList | list(string) | c | | | | | c | false | |
| LStrInsDef | list(string) | ["c"] | ["e"] | | | | ["c"] | true | |
| LStrIns/DefInv | list(string) | ["c"] | ["e"] | | [a-c] | | | | regex cannot |
| LStrInsOpts | list(string) | ["c"] | ["e"] | ["c"],["d"],["e"] | | | ["c"] | true | |
| LStrInsNotOpts | list(string) | ["c"] | ["e"] | ["d"],["e"] | | | ["c"] | true | |
| LStrInsNotOpts/NoDef | list(string) | ["c"] | | ["d"],["e"] | | | ["c"] | false | |
| | | | | | | | | | |
| MulInsOpts | multi-select | ["c"] | ["e"] | c,d,e | | | ["c"] | true | |
| MulInsNotListOpts | multi-select | c | ["e"] | c,d,e | | | c | true | |
| MulInsNotOpts | multi-select | ["c"] | ["e"] | d,e | | | ["c"] | true | |
| MulInsNotOpts/NoDef | multi-select | ["c"] | | d,e | | | ["c"] | false | |
| MulInsInvOpts | multi-select | ["c"] | ["e"] | c,d,e | [a-c] | | | | regex cannot |
Loading

[8]ページ先頭

©2009-2025 Movatter.jp