Skip to content

fix: terraform-plugin-sdk zeros *int fields #123

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 1, 2023
Merged
Changes from 1 commit
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
28 changes: 28 additions & 0 deletions provider/parameter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@ func TestParameter(t *testing.T) {
ExpectError *regexp.Regexp
Check func(state *terraform.ResourceState)
}{{
Name: "NumberValidation_Max",
Config: `
data "coder_parameter" "region" {
name = "Region"
type = "number"
default = 2
validation {
max = 9
}
}
`,
Check: func(state *terraform.ResourceState) {
for key, expected := range map[string]string{
"name": "Region",
"type": "number",
"validation.#": "1",
"default": "2",
"validation.0.max": "9",
} {
require.Equal(t, expected, state.Primary.Attributes[key])
}

_, foundDisplayName := state.Primary.Attributes["display_name"]
require.False(t, foundDisplayName, "display_name = "+state.Primary.Attributes["display_name"])
_, foundValidationMin := state.Primary.Attributes["validation.0.min"]
require.False(t, foundValidationMin, "validation.0.min = "+state.Primary.Attributes["validation.0.min"])
Copy link
Member Author

@mtojek mtojek May 30, 2023

Choose a reason for hiding this comment

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

@kylecarbs Maybe you have a clue what is the reason.

},
}, {
Name: "FieldsExist",
Config: `
data "coder_parameter" "region" {
Expand Down