-
Notifications
You must be signed in to change notification settings - Fork 4
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
Refactor tests to use testify require library #25
Conversation
bbea58a
to
17f10bc
Compare
Makes code cleaner and easier to read Co-authored-by: Andrea Rosa <[email protected]> Co-authored-by: Kevin Intriago <[email protected]>
17f10bc
to
da708b9
Compare
Hey. I came here because I really dislike assertion libraries and was curious about this pull request. The reasons I dislike are here: https://go.dev/doc/faq#assertions, but this isn't exactly why I'm writing this comment. The thing that concerned me is that I see that testify/require was used, and it calls t.FailNow (as in, t.Fatal).
If you really want to use an assertion library, you might want to consider using another package (like, ../assert) which uses t.Fail instead (as in, t.Error) to make sure you can use your checks inside goroutines concurrently safely. |
…hat assertions will run inside goroutines concurrently safely. Note that `go vet` will wanr about use of t.FailNow inside goroutines, but not if nested inside functions. Co-authored-by: Kevin Intriago <[email protected]>
Thanks @henrique-pinto-form3 for the feedback. I wasn't aware of this issue and it is always good to learn something new. It's interesting, perhaps slightly worrying, that I've updated the PR to use |
Using FailNow sometimes make sense. Not as common, but not a defect, so it wouldn't make sense for go vet to report it. Static analyzers can only do so much! |
if err != nil { | ||
s.t.Error(err) | ||
} | ||
s.require.NoError(err) |
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.
There was a general comment about calling FailNow
from @henrique-pinto-form3 . Doesn't this method still potentially end up calling t.FailNow
under the hood?
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.
I don't think this is a problem, we're not creating a goroutine as part of the stage setup?
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.
I intended to change all to assert, mainly for consistence, just overlooked this file. Will change.
7873c42
to
92d2976
Compare
Refactor test to make code cleaner and easier to read, as baseline for future improvements. The testify library provides excellent helper functions for test assertions, let's use them.
Work towards of investment time project: https://github.com/form3tech/investment-time-project/issues/62
Co-authored-by: Andrea Rosa [email protected]
Co-authored-by: Kevin Intriago [email protected]