Skip to content

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

Merged
mmorel-35 merged 1 commit intoenvoyproxy:mainfrom
mmorel-35:testifier/require-error
Jan 28, 2025
Merged

chore: use testify instead of t.Fatal or t.Error#1040
mmorel-35 merged 1 commit intoenvoyproxy:mainfrom
mmorel-35:testifier/require-error

Conversation

@mmorel-35
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@mmorel-35
Copy link
Copy Markdown
Contributor Author

mmorel-35 commented Dec 2, 2024

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

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
@mmorel-35 mmorel-35 force-pushed the testifier/require-error branch from 3fca00f to 04d5899 Compare December 2, 2024 20:16
@mmorel-35 mmorel-35 self-assigned this Jan 10, 2025
@mmorel-35 mmorel-35 enabled auto-merge (squash) January 11, 2025 14:40
@mmorel-35 mmorel-35 disabled auto-merge January 28, 2025 07:35
@mmorel-35 mmorel-35 merged commit a245442 into envoyproxy:main Jan 28, 2025
@mmorel-35 mmorel-35 deleted the testifier/require-error branch February 17, 2026 06:04
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