Skip to content

tidy(testutils): Relocate CompareResult#2944

Merged
Cobalt0s merged 1 commit into
mainfrom
cobalt0s/tests-compare-result
May 4, 2026
Merged

tidy(testutils): Relocate CompareResult#2944
Cobalt0s merged 1 commit into
mainfrom
cobalt0s/tests-compare-result

Conversation

@Cobalt0s
Copy link
Copy Markdown
Contributor

@Cobalt0s Cobalt0s commented May 1, 2026

Description

This PR refines and generalizes the recently introduced CompareResult.

Key changes

  • Package relocation
    The CompareResult type has been moved from mockutils to testutils.
    While mockutils is intended for provider-specific mocking utilities, CompareResult is a more general-purpose testing construct.

  • Improved AddDiff API
    CompareResult.AddDiff previously required preformatted messages (commonly via fmt.Sprintf).
    It now accepts a format string with variadic arguments, simplifying usage and reducing boilerplate.

  • Renamed assertion methods
    The main methods are now named Assert and AssertErr.
    Their return semantics have been updated to align with common testing conventions:

    • true indicates success
    • false indicates failure
      This replaces the previous, less intuitive behavior where true indicated an error.
  • Centralized validation logic
    Validation is now fully owned by CompareResult, from instantiation through the Validate stage.
    Calling Validate will invoke t.Fatal(...) if any assertions have failed, making failure handling explicit and easier to follow.

Copy link
Copy Markdown
Contributor Author

Cobalt0s commented May 1, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Cobalt0s
Copy link
Copy Markdown
Contributor Author

Cobalt0s commented May 1, 2026

@AmandaYao00 there are some improvements -- tidying of the CompareResult. Let me know if you are ok with the changes and if you have any suggestions to improve anything.

@Cobalt0s Cobalt0s force-pushed the cobalt0s/tests-compare-result branch 2 times, most recently from d8d8483 to 814b593 Compare May 1, 2026 17:33
Copy link
Copy Markdown
Contributor

@AmandaYao00 AmandaYao00 left a comment

Choose a reason for hiding this comment

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

Looks good!

Comment thread test/utils/testutils/comparison.go Outdated
@Cobalt0s Cobalt0s force-pushed the cobalt0s/tests-compare-result branch from 814b593 to 735cffd Compare May 4, 2026 22:12
@Cobalt0s Cobalt0s merged commit a8ad85e into main May 4, 2026
6 checks passed
@Cobalt0s Cobalt0s deleted the cobalt0s/tests-compare-result branch May 4, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants