Skip to content

Replace all uses of mtest.Background with context.Background() #839

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

Merged
merged 1 commit into from
Jan 19, 2022

Conversation

matthewdale
Copy link
Collaborator

There is currently an inconsistent mixture between use of context.Background() and mtest.Background context values in tests. Those two values are semantically and functionally identical, but mtest.Background requires additional knowledge of what that value is, where context.Background() is a more generally understood stdlib value.

Replace all uses of mtest.Background with context.Background() and remove the mtest.Background value.

Copy link
Contributor

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Added a few questions about whether additional go:build comments were intended. I do not think the answer will block the merge.

@@ -4,6 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

//go:build cse
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this intended to be included?

Regardless, adding go:build cse seems OK to add based on https://stackoverflow.com/a/68361186/774658.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good find! That wasn't intended to be included. As the linked article suggests, looks like it's automatically added by gofmt if you're using Go 1.17+.

Since it's the official Go formatter adding those and they're backwards-compatible with previous Go versions, I think we should keep them.

@@ -4,6 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

//go:build go1.13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intended to be included?

Copy link
Collaborator Author

@matthewdale matthewdale Jan 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above. Not intentional, but I think we should keep it.

@@ -4,6 +4,7 @@
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

//go:build go1.13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intended?

Copy link
Collaborator Author

@matthewdale matthewdale Jan 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above. Not intentional, but I think we should keep it.

Copy link
Contributor

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a fair change to me. Thanks. LG barring Kevin's question about the build tags.

@matthewdale matthewdale force-pushed the experiment_mtest_background branch from 49bd910 to 9699359 Compare January 19, 2022 17:57
@matthewdale matthewdale merged commit 2a39aae into mongodb:master Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants