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

helper/resource: Return error with TestCheckResourceAttrPair() when comparing self #335

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Feb 21, 2020

Closes #334

Also consolidates the unit testing for the function.

@bflad bflad requested a review from a team February 21, 2020 14:07
@@ -1232,6 +1232,14 @@ func TestCheckModuleResourceAttrPair(mpFirst []string, nameFirst string, keyFirs
}

func testCheckResourceAttrPair(isFirst *terraform.InstanceState, nameFirst string, keyFirst string, isSecond *terraform.InstanceState, nameSecond string, keySecond string) error {
if nameFirst == nameSecond && keyFirst == keySecond {
Copy link
Contributor

Choose a reason for hiding this comment

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

While I like the enhancement, I'm inclined to think in V1 maybe this should just be a warning like "you may be comparing an attribute with itself". We can make it an explicit error in V2.... tough one kind of a grey area on if this is a "breaking change" or a bugfix. I could be convinced either way.

Copy link
Contributor

Choose a reason for hiding this comment

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

But yeah, would the warning ever get noticed in review/during development vs explicit error, it certainly is valuable in avoiding accidental merging of true == true when a PR is showing all tests passing.

@appilon
Copy link
Contributor

appilon commented Mar 4, 2020

@bflad I am going to take the liberty of rebasing with version2 and merging it there as its safer.

@appilon appilon added the breaking-change Implementation which breaks compatibility or other promises label Mar 4, 2020
@appilon appilon added this to the v2.0.0 milestone Mar 4, 2020
…omparing self

Reference: hashicorp#334

Also consolidates the unit testing for the function.
@appilon appilon force-pushed the b-helper-resource-TestCheckResourceAttrPair-self branch from f4043b8 to 73effae Compare March 4, 2020 00:31
@appilon appilon changed the base branch from master to version2 March 4, 2020 00:31
@appilon appilon merged commit ee2b66e into hashicorp:version2 Mar 4, 2020
@ghost
Copy link

ghost commented Apr 3, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking-change Implementation which breaks compatibility or other promises
Projects
None yet
Development

Successfully merging this pull request may close these issues.

helper/resource.TestCheckResourceAttrPair() Does Not Return Error If Comparing Self
2 participants