Skip to content

Conversation

@SarahFrench
Copy link
Member

@SarahFrench SarahFrench commented Feb 11, 2025

Moves these functions into testing.go in the tfdiags package:

  • AssertNoDiagnostics
  • AssertDiagnosticCount
  • AssertNoErrors
  • LogDiagnostics

Removes implementations of these functions from other packages
Refactors existing tests to use the new helpers in tfdiags

Target Release

N/A

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@SarahFrench SarahFrench added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Feb 11, 2025
Base automatically changed from sarah/diags-comparisons-refactor to main February 19, 2025 13:59
@SarahFrench SarahFrench force-pushed the sarah/diags-comparisons-refactor-2 branch from 127c61f to 457b09a Compare March 24, 2025 09:48
@SarahFrench SarahFrench force-pushed the sarah/diags-comparisons-refactor-2 branch from 457b09a to c03e7d7 Compare March 24, 2025 09:50
Copy link
Member Author

@SarahFrench SarahFrench left a comment

Choose a reason for hiding this comment

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

Highlighting where the helper functions used to be located

Comment on lines -1000 to -1016
func assertNoDiagnostics(t *testing.T, diags tfdiags.Diagnostics) bool {
t.Helper()
return assertDiagnosticCount(t, diags, 0)
}

func assertDiagnosticCount(t *testing.T, diags tfdiags.Diagnostics, want int) bool {
t.Helper()
if len(diags) != want {
t.Errorf("wrong number of diagnostics %d; want %d", len(diags), want)
for _, diag := range diags {
t.Logf("- %#v", diag)
}
return true
}
return false
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed functions here

Copy link
Member Author

@SarahFrench SarahFrench Mar 24, 2025

Choose a reason for hiding this comment

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

This is the other place where helper functions were moved from

@SarahFrench SarahFrench marked this pull request as ready for review March 24, 2025 10:51
@SarahFrench SarahFrench requested a review from a team as a code owner March 24, 2025 10:51
@SarahFrench SarahFrench merged commit 052646c into main Mar 24, 2025
8 checks passed
@SarahFrench SarahFrench deleted the sarah/diags-comparisons-refactor-2 branch March 24, 2025 14:20
rkoron007 pushed a commit that referenced this pull request Mar 27, 2025
* Add new `AssertNoDiagnostics` and `AssertDiagnosticCount` test helpers in tfdiags package

* Add new `AssertNoErrors` and `LogDiagnostics` test helpers in tfdiags package

* Refactor existing tests to use new helpers

* Refactor more recent tests

* Revert change - wrong function replaced

* Refactor to account for function no longer returning a boolean

* Fix comment
@github-actions
Copy link
Contributor

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 Apr 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelog-needed Add this to your PR if the change does not require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants