Modernize tests#428
Closed
dgageot wants to merge 3 commits into
Closed
Conversation
Replace context.Background() with t.Context() in test files for modern Go testing patterns (Go 1.24+). Assisted-By: cagent
Add golangci-lint rules to enforce: - Using t.TempDir() instead of os.MkdirTemp in tests - Using t.Context() instead of context.Background()/TODO() in tests - No print statements in test code Assisted-By: cagent
Benehiko
previously approved these changes
Jan 21, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modernizes Go test code by replacing manual context.Background() calls with the newer t.Context() method introduced in Go 1.18. The changes also add linter rules to enforce this pattern going forward.
Changes:
- Updated test code to use
t.Context()instead ofcontext.Background() - Added
forbidigolinter rules to prevent future use of deprecated test patterns - Configured linter to scope test-specific rules to test files only
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| store/keychain/keychain_test.go | Replaced context.Background() with t.Context() in cleanup functions |
| engine/internal/runtime/plugin_test.go | Replaced context.Background() with t.Context() in plugin test assertions |
| .golangci.yml | Added forbidigo linter with rules to enforce modern test patterns |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This was produced by a cagent based agent that looks for modern Go test api usage.