Skip to content

Conversation

@richie-king
Copy link

@richie-king richie-king commented Nov 29, 2025

Proposed changes

Problem: Unit tests currently use context.TODO() and context.Background(), which can potentially lead to goroutine leaks and resource cleanup issues because these contexts are not automatically canceled when a test completes.

Solution: Replaced usage of context.TODO() and context.Background() with t.Context() in unit tests. This ensures that contexts are automatically canceled when tests complete and aligns the test suite with modern Go 1.24+ testing practices.

Testing: Ran all unit tests to ensure they pass with the new context handling.
Closes #3157

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the contributing guidelines.
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Release notes

If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.

Refactored unit tests to use t.Context() instead of context.TODO() or context.Background() to prevent potential goroutine leaks.

@nginx-bot
Copy link

nginx-bot bot commented Nov 29, 2025

Hi @richie-king! Welcome to the project! 🎉

Thanks for opening this pull request!
Be sure to check out our Contributing Guidelines while you wait for someone on the team to review this.

@nginx-bot nginx-bot bot added the community label Nov 29, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 29, 2025

✅ All required contributors have signed the F5 CLA for this PR. Thank you!
Posted by the CLA Assistant Lite bot.

@github-actions github-actions bot added the tests Pull requests that update tests label Nov 29, 2025
@richie-king
Copy link
Author

richie-king commented Nov 29, 2025

🎉 Thank you for your contribution! It appears you have not yet signed the F5 Contributor License Agreement (CLA), which is required for your changes to be incorporated into an F5 Open Source Software (OSS) project. Please kindly read the F5 CLA and reply on a new comment with the following text to agree:

I have hereby read the F5 CLA and agree to its terms

You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

I have hereby read the F5 CLA and agree to its terms

@richie-king
Copy link
Author

recheck

@richie-king
Copy link
Author

I have hereby read the F5 CLA and agree to its terms

@richie-king
Copy link
Author

recheck

@richie-king richie-king changed the title test: replace context.TODO and context.Background to t.Context in uni… Test: replace context.TODO and context.Background to t.Context in uni… Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community tests Pull requests that update tests

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

Update unit tests to use new test Context

1 participant