Skip to content
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

Add framework function object parameter attribute requiredness tests #226

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Mar 15, 2024

Reference: hashicorp/terraform-plugin-framework#955

This adds acceptance tests that capture the linked issue around object parameter attribute requiredness with the existing behavior of Terraform and available functionality of the framework. These are being added as regression checks should framework functionality ever be introduced that either automatically or enables developers to make object attributes optional. It should be considered a breaking change should the existing function definition begin not causing an error, as provider developers may be reliant and desire this existing behavior for their use cases.

Without ErrorCheck (and temporarily TerraformVersionChecks to workaround prerelease issues):

=== CONT  TestObjectFunction_Known_AttributeRequired_Error
    object_function_test.go:53: Step 1/1 error: Error running pre-apply plan: exit status 1

        Error: Invalid function argument

          on terraform_plugin_test.tf line 13, in output "test":
          13:                                   value = provider::framework::object({
          14:                                           "attr1" = "value1",
          15:                                   })
            ├────────────────
            │ while calling provider::framework::object(param1)

        Invalid value for "param1" parameter: attribute "attr2" is required.
--- FAIL: TestObjectFunction_Known_AttributeRequired_Error (0.30s)

With ErrorCheck:

--- PASS: TestObjectFunction_Known_AttributeRequired_Error (0.48s)
--- PASS: TestObjectFunction_Known_AttributeRequired_Null (0.53s)

Reference: hashicorp/terraform-plugin-framework#955

This adds acceptance tests that capture the linked issue around object parameter attribute requiredness with the existing behavior of Terraform and available functionality of the framework. These are being added as regression checks should framework functionality ever be introduced that either automatically or enables developers to make object attributes optional. It should be considered a breaking change should the existing function definition begin not causing an error, as provider developers may be reliant and desire this existing behavior for their use cases.

Without `ErrorCheck` (and temporarily `TerraformVersionChecks` to workaround prerelease issues):

```
=== CONT  TestObjectFunction_Known_AttributeRequired_Error
    object_function_test.go:53: Step 1/1 error: Error running pre-apply plan: exit status 1

        Error: Invalid function argument

          on terraform_plugin_test.tf line 13, in output "test":
          13:                                   value = provider::framework::object({
          14:                                           "attr1" = "value1",
          15:                                   })
            ├────────────────
            │ while calling provider::framework::object(param1)

        Invalid value for "param1" parameter: attribute "attr2" is required.
--- FAIL: TestObjectFunction_Known_AttributeRequired_Error (0.30s)
```

With `ErrorCheck`:

```
--- PASS: TestObjectFunction_Known_AttributeRequired_Error (0.48s)
--- PASS: TestObjectFunction_Known_AttributeRequired_Null (0.53s)
```
@bflad bflad requested a review from a team as a code owner March 15, 2024 18:51
Copy link
Member

@austinvalle austinvalle left a comment

Choose a reason for hiding this comment

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

🚀 🚀 🚀

@bflad bflad merged commit add5dd4 into main Mar 15, 2024
64 checks passed
@bflad bflad deleted the bflad/framework-object-parameter-requiredness branch March 15, 2024 19:03
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants