-
Notifications
You must be signed in to change notification settings - Fork 62
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
Conversation
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>
There was a problem hiding this 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
runutil/runutil_test.go
Outdated
expectedErrStr: "2 errors: test; close: test", | ||
}, | ||
} { | ||
if ok := t.Run("", func(t *testing.T) { |
There was a problem hiding this comment.
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
andt.Error
when we're already importing testify assert - Using
t.Run()
with an empty test name?
runutil/runutil_test.go
Outdated
|
||
CloseWithLogOnErr(lc, r, "should not be called") | ||
CloseWithLogOnErr(lc, r, "should not be called") | ||
assert.Equal(t, false, lc.WasCalled) |
There was a problem hiding this comment.
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>
I changed the tests as suggested by @56quarters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM :)
Thanks! |
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
CHANGELOG.md
updated