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

Avoid using context.Background in tests #1878

Closed
menghanl opened this issue Feb 20, 2018 · 3 comments · Fixed by #3949
Closed

Avoid using context.Background in tests #1878

menghanl opened this issue Feb 20, 2018 · 3 comments · Fixed by #3949

Comments

@menghanl
Copy link
Contributor

context.Background is used in many tests/benchmarks. Which might be misleading for users.

Some of the tests expect an error, so context.Background is probably OK.
We should check and make sure context.Background doesn't cause any problem.

@stale
Copy link

stale bot commented Sep 6, 2019

This issue is labeled as requiring an update from the reporter, and no update has been received after 7 days. If no update is provided in the next 7 days, this issue will be automatically closed.

@gauravgahlot
Copy link
Contributor

@dfawley I would like to take this up.

@dfawley
Copy link
Member

dfawley commented Oct 2, 2020

Sounds great, thank you!

I would do a grep for context.Background() in our tests (* - see below); any usages should appear in a context.WithTimeout or context.WithDeadline call as a rule. It's possible some tests add a timeout later, or a deadline isn't relevant for some tests, but I believe those should be rare.

* - find . -name '*_test.go' | xargs grep -F 'context.Background()'

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants