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

testing: Replace state extract with new value comparers #345

Merged
merged 5 commits into from
Aug 8, 2024

Conversation

austinvalle
Copy link
Member

Ref: hashicorp/terraform-plugin-testing#295

Here is an example failure if you remove the time.Sleep test statements now:

--- FAIL: TestAccTimeStatic_Triggers (0.88s)
    /Users/austin.valle/code/terraform-provider-time/internal/provider/resource_time_static_test.go:58: Step 3/3 error: Post-apply refresh state check(s) failed:
        expected values to differ, but they are the same: 2024-08-07T16:13:29Z == 2024-08-07T16:13:29Z
FAIL
FAIL	github.com/hashicorp/terraform-provider-time/internal/provider	1.556s
FAIL

@austinvalle austinvalle requested a review from a team as a code owner August 7, 2024 16:20
@github-actions github-actions bot added dependencies Pull requests that update a dependency file size/L labels Aug 7, 2024
go.mod Outdated Show resolved Hide resolved
@austinvalle austinvalle marked this pull request as draft August 7, 2024 16:31
Comment on lines -201 to -204
// Ensure the id time value is different due to the sleep
if captureTimeState1.Value == captureTimeState2.Value {
t.Fatal("attribute values are the same")
}
Copy link
Member Author

@austinvalle austinvalle Aug 7, 2024

Choose a reason for hiding this comment

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

Quick note here since I'm reversing the assertion of this test. The original test was actually asserting the values were the same, but I must've missed that in #295, where I attempted to add this (which it would have failed if I wrote it correctly 😆). This test has been passing since because it's comparing pointer addresses and not the actual string values.

Comment on lines -247 to -250
// Ensure the id time value is different due to the sleep
if captureTimeState1.Value == captureTimeState2.Value {
t.Fatal("attribute values are the same")
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@austinvalle austinvalle marked this pull request as ready for review August 7, 2024 21:56
@austinvalle austinvalle merged commit d9ef8c4 into main Aug 8, 2024
47 checks passed
@austinvalle austinvalle deleted the av/value-comparers branch August 8, 2024 21:41
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dependencies Pull requests that update a dependency file size/L technical-debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants