Skip to content

Change assertion calls to use testing.TB interface#53

Merged
sebdah merged 2 commits intosebdah:masterfrom
draxel-ai:improve-testing-extensibility
Oct 11, 2025
Merged

Change assertion calls to use testing.TB interface#53
sebdah merged 2 commits intosebdah:masterfrom
draxel-ai:improve-testing-extensibility

Conversation

@jono-tt
Copy link
Copy Markdown

@jono-tt jono-tt commented Sep 29, 2025

This PR is to make extending goldie easier in the consumer. This was to change the assertions to using the TB interface which makes overriding functions within the testing framework possible to override.
An example of issues this solves is that if you want to override the FailNow call's to intercept this failure before failing the test, using the interface makes this possible rather than using the concrete testing.T type.

This also exposes the get golden file to a public function to assist in retrieving golden test files.

@jono-tt jono-tt force-pushed the improve-testing-extensibility branch 3 times, most recently from 1a58b55 to d220736 Compare September 29, 2025 20:28
…File data to allow easy reading of golden files
@jono-tt jono-tt force-pushed the improve-testing-extensibility branch from d220736 to 188fad9 Compare September 29, 2025 20:34
Comment thread v2/interface.go Outdated
// options to an OptionProcessor.
type Option func(OptionProcessor) error

type TB testing.TB
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why adding this interface while you could have used testing.TB directly in the Tester interface ?

There is nothing wrong with this, but I don't see the point here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It was to have an interface that could be extended later but i see there is another interface already in the project for that purpose, I have changed to the testing.TB interface.

Comment thread .gitignore Outdated
@jono-tt
Copy link
Copy Markdown
Author

jono-tt commented Oct 8, 2025

Thanks for approval @ccoVeille. @sebdah are you able to have a look?

@sebdah
Copy link
Copy Markdown
Owner

sebdah commented Oct 11, 2025

Looks great, thanks for this!

@sebdah sebdah merged commit c0dbdf7 into sebdah:master Oct 11, 2025
1 check passed
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.

3 participants