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

testifylint: enable require-error #5034

Merged
merged 1 commit into from
Dec 24, 2023
Merged

testifylint: enable require-error #5034

merged 1 commit into from
Dec 24, 2023

Conversation

mmorel-35
Copy link
Contributor

@mmorel-35 mmorel-35 commented Dec 24, 2023

Which problem is this PR solving?

  • Apply require-error rule of testifylint

Description of the changes

  • use require instead of assert on errors testing

How was this change tested?

  • CI

Checklist

Copy link

codecov bot commented Dec 24, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (cf917dd) 52.59% compared to head (9a56e40) 95.61%.

Files Patch % Lines
plugin/storage/integration/trace_compare.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5034       +/-   ##
===========================================
+ Coverage   52.59%   95.61%   +43.01%     
===========================================
  Files         145      319      +174     
  Lines        8599    18794    +10195     
===========================================
+ Hits         4523    17970    +13447     
+ Misses       3728      661     -3067     
+ Partials      348      163      -185     
Flag Coverage Δ
cassandra-3.x 25.61% <40.00%> (ø)
cassandra-4.x 25.61% <40.00%> (ø)
elasticsearch-5.x 19.87% <20.00%> (-0.02%) ⬇️
elasticsearch-6.x 19.87% <20.00%> (-0.02%) ⬇️
elasticsearch-7.x 20.02% <20.00%> (ø)
elasticsearch-8.x 20.09% <20.00%> (-0.02%) ⬇️
grpc-badger 19.50% <0.00%> (-0.02%) ⬇️
kafka 14.10% <0.00%> (ø)
opensearch-1.x 20.02% <20.00%> (ø)
opensearch-2.x 20.00% <20.00%> (-0.02%) ⬇️
unittests 93.35% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mmorel-35 mmorel-35 marked this pull request as ready for review December 24, 2023 19:06
@mmorel-35 mmorel-35 requested a review from a team as a code owner December 24, 2023 19:06
@yurishkuro yurishkuro added the changelog:test Change that's adding missing tests or correcting existing tests label Dec 24, 2023
@yurishkuro
Copy link
Member

this one is impossible to review manually, can you describe how the PR was made? Are there any manual changes, or is everything just s/assert/require/?

Copy link
Contributor Author

@mmorel-35 mmorel-35 left a comment

Choose a reason for hiding this comment

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

Except the two quoted changes in this comments, this replaces all assert.{NoError,Error,ErrorContains,ErrorIs,EqualError} methods by require.{NoError,Error,ErrorContains,ErrorIs,EqualError}

Would you prefer to split this PR by package of around 30 files maybe ?

@@ -53,21 +53,18 @@ func TestTraceIDMarshalJSONPB(t *testing.T) {
ref := model.SpanRef{TraceID: model.NewTraceID(testCase.hi, testCase.lo)}
out := new(bytes.Buffer)
err := new(jsonpb.Marshaler).Marshal(out, &ref)
if assert.NoError(t, err) {
Copy link
Contributor Author

@mmorel-35 mmorel-35 Dec 24, 2023

Choose a reason for hiding this comment

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

This is the first kind of adaptation I had to do .
Remove the if and use a require instead.

This happens 6 times and only in this file

Copy link
Member

Choose a reason for hiding this comment

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

yeah, in this case it's safe to replace it like this, but it's not always the case.

@@ -607,14 +607,14 @@ func BenchmarkServiceIndexLimitFetch(b *testing.B) {

// Opens a badger db and runs a test on it.
func runLargeFactoryTest(tb testing.TB, test func(tb testing.TB, sw spanstore.Writer, sr spanstore.Reader)) {
assert := assert.New(tb)
assertion := require.New(tb)
Copy link
Contributor Author

@mmorel-35 mmorel-35 Dec 24, 2023

Choose a reason for hiding this comment

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

I also created require assertions instead of assert .

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

Thanks!

@yurishkuro yurishkuro merged commit 7d1cc9f into jaegertracing:main Dec 24, 2023
36 of 39 checks passed
@mmorel-35 mmorel-35 deleted the testifylint/require-error branch December 25, 2023 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:test Change that's adding missing tests or correcting existing tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants