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

Consider adding Tuple* known value checks #312

Closed
austinvalle opened this issue Mar 25, 2024 · 1 comment · Fixed by #313
Closed

Consider adding Tuple* known value checks #312

austinvalle opened this issue Mar 25, 2024 · 1 comment · Fixed by #313
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@austinvalle
Copy link
Member

terraform-plugin-testing version

v1.7.0

Proposal

Now that dynamic type support is in plugin framework, it's possible that provider developers will test dynamic data that could be a tuple. For readability, we should introduce equivalent TupleExact, TuplePartial, and TupleSize known value checks.

Workaround

Currently, you can test this with the List* equivalents, since no restriction is applied for knownvalue checks to be all the same type. Example with ListExact:

func TestDynamicSchemaResource_DynamicAttribute(t *testing.T) {
    resource.UnitTest(t, resource.TestCase{
        ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){
            "framework": providerserver.NewProtocol5WithError(New()),
        },
        Steps: []resource.TestStep{
            {
                Config: `resource "framework_dynamic_schema" "test" {
                    dynamic_attribute = [true, 1234.5]
                }`,
                ConfigStateChecks: []statecheck.StateCheck{
                    statecheck.ExpectKnownValue("framework_dynamic_schema.test", tfjsonpath.New("dynamic_attribute"),
                        knownvalue.ListExact(
                            []knownvalue.Check{
                                knownvalue.Bool(true),
                                knownvalue.NumberExact(big.NewFloat(1234.5)),
                            },
                        ),
                    ),
                },
            },
        },
    })
}
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, 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 Apr 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
1 participant