-
Notifications
You must be signed in to change notification settings - Fork 7
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
Ignore requests in tests #6
Comments
Thank you for opening your issue! I'll fix it. |
If you need a quick fix, please use golangci-lint. Usage Exec golangci-lint without test files. |
Thanks for the hint. I actually do want to lint my test files. Just not for the usage of the context :) For now, I just excluded |
I understand your situation. Can you try again golangci-lint with following
|
Thanks, @sonatard. That's a good temporary workaround! |
As described in the docs,
http.NewRequest
uses thecontext.Background
context which is supposed to be used in tests according to the docs. Therefore, it is cleaner to usehttp.NewContext
in tests where we make HTTP requests against test servers.Therefore, I think the linter should allow the usage of
http.NewRequest
,http.Get
,http.Header
and all similar functions in tests because it's the recommended way and provides much simpler code than having to explicitly usehttp.NewRequestWithContext
withcontext.Background
each time.The text was updated successfully, but these errors were encountered: