Skip to content

Add testing helpers that allow comparing diagnostics, refactor existing tests to use them. #36456

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

Merged
merged 7 commits into from
Feb 19, 2025

Conversation

SarahFrench
Copy link
Member

@SarahFrench SarahFrench commented Feb 6, 2025

This PR introduces testing helpers for comparing diagnostics in the tfdiags package.

Summary:

  • There was a pre-existing helper in the terraform package -assertDiagnosticsMatch- that I've replaced in this PR.
  • I've replaced use of cmp.Diff(want, got, DiagnosticComparer) with the helper that does that internally
  • I've refactored code that purposefully converted Diagnostics to RPC-friendly versions into using the new helper, as the helper does that internally

Open questions:

  • Which tests would want to assert the concrete type of a returned diagnostic?

There are some other test helpers that can be moved into tfdiags/testing.go, but I'll save that for subsequent PRs due to the large number of diffs that refactoring causes.

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 6, 2025
@SarahFrench SarahFrench changed the title Sarah/diags comparisons refactor Add testing helpers that allow comparing diagnostics, refactor existing tests to use them. Feb 6, 2025
@SarahFrench SarahFrench force-pushed the sarah/diags-comparisons-refactor branch from 74c2680 to 4f670a5 Compare February 7, 2025 10:20
@SarahFrench SarahFrench force-pushed the sarah/diags-comparisons-refactor branch from 4f670a5 to 2635a30 Compare February 11, 2025 17:40
@SarahFrench SarahFrench changed the base branch from sarah/diags-comparisons to main February 11, 2025 17:41
@SarahFrench SarahFrench force-pushed the sarah/diags-comparisons-refactor branch from 2635a30 to 1d8c86b Compare February 11, 2025 17:43
@SarahFrench SarahFrench marked this pull request as ready for review February 11, 2025 18:08
@SarahFrench SarahFrench requested a review from a team as a code owner February 11, 2025 18:08
DanielMSchmidt
DanielMSchmidt previously approved these changes Feb 12, 2025
@SarahFrench
Copy link
Member Author

👆🏻 Had a merge conflict

@SarahFrench SarahFrench merged commit 85b482e into main Feb 19, 2025
8 checks passed
@SarahFrench SarahFrench deleted the sarah/diags-comparisons-refactor branch February 19, 2025 13:59
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 Mar 22, 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.

3 participants