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

runtutil: add ExhaustCloseWithErrCapture #210

Merged
merged 2 commits into from
Aug 31, 2022
Merged

runtutil: add ExhaustCloseWithErrCapture #210

merged 2 commits into from
Aug 31, 2022

Conversation

bboreham
Copy link
Contributor

@bboreham bboreham commented Aug 9, 2022

Code from https://github.com/thanos-io/thanos/blob/6d1b98d49781/pkg/runutil/, slightly modified for consistency.

This enables grafana/e2e to build without a dependency on Thanos - grafana/e2e#4

Checklist

  • Tests updated
  • NA CHANGELOG.md updated

Code from https://github.com/thanos-io/thanos/blob/6d1b98d49781/pkg/runutil/,
slightly modified for consistency.

This enables grafana/e2e to build without a dependency on Thanos.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
@CLAassistant
Copy link

CLAassistant commented Aug 9, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@56quarters 56quarters left a comment

Choose a reason for hiding this comment

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

Code seems fine but the tests are a bit rough

expectedErrStr: "2 errors: test; close: test",
},
} {
if ok := t.Run("", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a really odd way to structure this test (I assume this is a verbatim copy of the Thanos tests?)

  • Conditionals in the test body for the various test cases instead of having three separate tests ala t.Run("something", ...)
  • Using t.Fail and t.Error when we're already importing testify assert
  • Using t.Run() with an empty test name?


CloseWithLogOnErr(lc, r, "should not be called")
CloseWithLogOnErr(lc, r, "should not be called")
assert.Equal(t, false, lc.WasCalled)
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be replaced with assert.False or assert.True

Use assert/require where possible.

Supply a name to t.Run().

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
@bboreham
Copy link
Contributor Author

I changed the tests as suggested by @56quarters.

Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Still LGTM :)

@56quarters
Copy link
Contributor

I changed the tests as suggested by @56quarters.

Thanks!

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.

None yet

4 participants