Skip to content

Modernize tests#350

Closed
dgageot wants to merge 4 commits intodocker:mainfrom
dgageot:modernize-tests
Closed

Modernize tests#350
dgageot wants to merge 4 commits intodocker:mainfrom
dgageot:modernize-tests

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Jan 20, 2026

What I did

I tried to use a cagent based agent to modernize the Go unit tests as much as possible.

Use the modern t.Chdir() helper instead of manual os.Chdir/defer
patterns for cleaner test code with automatic cleanup.

Assisted-By: cagent
Use the modern t.Setenv() helper instead of manual os.Setenv/defer
os.Unsetenv patterns for cleaner test code with automatic cleanup.

Updated files:
- cmd/docker-mcp/catalog/reset_test.go
- cmd/docker-mcp/commands/bootstrap_test.go
- cmd/docker-mcp/commands/catalog_validation_test.go
- cmd/docker-mcp/commands/export_test.go
- pkg/catalog/catalog_test.go
- pkg/gateway/auth_test.go
- pkg/gateway/auth_integration_test.go
- pkg/gateway/dynamic_mcps_test.go
- pkg/gateway/handlers_resource_telemetry_test.go
- pkg/migrate/migrate_test.go
- pkg/oauth/credhelper_test.go

Assisted-By: cagent
Use the modern t.Context() helper instead of context.Background() for
test contexts. This provides automatic context cancellation when tests
complete or fail.

Updated files:
- cmd/docker-mcp/commands/catalog_validation_test.go
- cmd/docker-mcp/commands/mcpregistry_test.go
- cmd/docker-mcp/server/inspect_test.go
- cmd/docker-mcp/tools/tools_test.go
- pkg/catalog/catalog_test.go
- pkg/elicitation_integration_test.go
- pkg/gateway/auth_integration_test.go
- pkg/gateway/clientpool_test.go
- pkg/gateway/configuration_test.go
- pkg/gateway/dynamic_mcps_test.go
- pkg/gateway/embeddings/client_test.go
- pkg/gateway/handlers_prompt_telemetry_test.go
- pkg/gateway/handlers_resource_telemetry_test.go
- pkg/gateway/handlers_telemetry_test.go
- pkg/integration_test.go
- pkg/interceptors/github_unauthorized_test.go
- pkg/interceptors/interceptors_test.go
- pkg/mcp/stdio_test.go
- pkg/oauth/callback_server_test.go
- pkg/oauth/manager_test.go
- pkg/remote_headers_integration_test.go
- pkg/telemetry/telemetry_test.go
- pkg/toollist_notifications_integration_test.go

Assisted-By: cagent
Add forbidigo rules to catch usage of:
- context.Background()/context.TODO() in tests (use t.Context())
- os.MkdirTemp() in tests (use t.TempDir())
- os.Setenv() in tests (use t.Setenv())

These rules only apply to *_test.go files via path-except exclusions.

Also updated remote_headers_integration_test.go to use t.Cleanup()
instead of defer/close pattern to avoid storing context in struct.

Note: analyze-types must be enabled for pkg filtering to work.

Assisted-By: cagent
@dgageot dgageot requested a review from a team as a code owner January 20, 2026 09:14
@dgageot dgageot closed this Jan 30, 2026
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.

1 participant

Comments