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

chore: use testify instead of t.Fatal or t.Error #1040

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mmorel-35
Copy link
Contributor

This uses testify instead of testing for t.Fatal or t.Error calls

@mmorel-35 mmorel-35 force-pushed the testifier/require-error branch 4 times, most recently from 456808d to c527e51 Compare November 5, 2024 22:25
@mmorel-35 mmorel-35 marked this pull request as ready for review November 5, 2024 22:46
valerian-roche
valerian-roche previously approved these changes Dec 2, 2024
if !cmp.Equal(want, got, protocmp.Transform()) {
t.Errorf("got resources %v, want %v", got, want)
}
assert.Truef(t, cmp.Equal(want, got, protocmp.Transform()), "got resources %v, want %v", got, want)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, using cmp.Diff in the error message makes it much simpler to process errors imo

if reflect.DeepEqual(streams[testTypes[0]].GetResourceVersions(), nextVersionMap) {
t.Fatalf("versionMap for the endpoint resource type did not change, received: %v, instead of an empty map", nextVersionMap)
}
require.Falsef(t, reflect.DeepEqual(streams[testTypes[0]].GetResourceVersions(), nextVersionMap), "versionMap for the endpoint resource type did not change, received: %v, instead of an empty map", nextVersionMap)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same remark: using cmp.Equal/cmp.Diff could be nicer in error messages

pkg/cache/v3/linear_test.go Show resolved Hide resolved
pkg/cache/v3/linear_test.go Show resolved Hide resolved
@mmorel-35
Copy link
Contributor Author

mmorel-35 commented Dec 2, 2024

Thank you @valerian-roche
Would you mind addingsuggestions I can apply ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants