Skip to content

Conversation

@jsoriano
Copy link
Member

Go 1.24.0 introduced a context in testing objects that is cancelled after the test is finished, but before registered cleanup functions are executed. See https://tip.golang.org/doc/go1.24#testingpkgtesting.

Apart from providing a non-nil context, this new context helps ensuring that resources that should be finished by context cancellation are actually finished.

In general there is no reason to don't use this context, the only reasons would be:

  • Contexts in cleanup functions, as this context will be cancelled at this point.
  • Contexts for resources that should persist along tests. Something I think we don't have in this project.
@jsoriano jsoriano requested a review from a team August 28, 2025 09:20
@jsoriano jsoriano self-assigned this Aug 28, 2025
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

cc @jsoriano

Copy link
Contributor

@mrodm mrodm left a comment

Choose a reason for hiding this comment

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

🚀

@jsoriano jsoriano merged commit 0c27f7c into elastic:main Sep 3, 2025
3 checks passed
@jsoriano jsoriano deleted the use-testing-context branch September 3, 2025 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants