-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use require a lot more than assert in js tests #2564
Conversation
This PR will be squashed upon merging. I have separate commits as that was easier to work with locally. You can review them all at the same time, but I would recommend disabling whitespace diffing ;) |
|
||
f, err := os.Open(logFilename) | ||
assert.NoError(t, err) | ||
f, err = os.Open(logFilename) //nolint:gosec |
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 is weird 😕 getSimpleRunner()
uses afero.NewMemMapFs()
by default, so why (and how) are we polluting the real filesystem here? 😕
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.
We don't use afero in the console code at all - I guess this is a thing we can open a issue about 🤔
Line 44 in aa06414
f, err := os.OpenFile(filepath, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0o644) //nolint:gosec |
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.
hmm... 🤔 yeah, please open an issue, we should fix this 😞
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 problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The js tests had a bunch of places where they were using
assert
instead ofrequire
.Mostly cases where the test should've not continued such as expecting error or no error. In some places
if assert....
was used which also is completely not needed.I have kept most usage of
assert
where they will report multiple (and even singular failures sometimes), but I would argue in most cases just usingrequire
for everything is likely enough.There are also a few places where I've added
requires
that were previously missing.Finally, there are few places that could've been left as
assert
but I decided to go forrequire
in order for there to be noassert.Error
for example. As I would argue this should always be with require.Some of those lead to fewer reported failures as previously an
if assert ...
was followed by more code that could run even if that assert is a failure. But I would argue in all of those cases that is unlikely, and even if that happens this particular failures will likely not help debug the original problem.