[test-improver] Improve tests for proxy.New and proxy.Handler by github-actions[bot] · Pull Request #8464 · github/gh-aw-mcpg · GitHub
Skip to content

[test-improver] Improve tests for proxy.New and proxy.Handler#8464

Merged
lpcox merged 1 commit into
mainfrom
test-improver/proxy-new-handler-coverage-8b1116335cd98991
Jul 2, 2026
Merged

[test-improver] Improve tests for proxy.New and proxy.Handler#8464
lpcox merged 1 commit into
mainfrom
test-improver/proxy-new-handler-coverage-8b1116335cd98991

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds unit tests for two completely uncovered functions in internal/proxy/proxy.go.

File Analyzed

internal/proxy/proxy_server_test.go (new file)
Implementation: internal/proxy/proxy.go

Improvements Made

Added 4 tests covering previously untested code paths:

Test Path Covered
TestNew_EmptyWasmPath cfg.WasmPath == "" guard (lines 90-92)
TestNew_InvalidWasmPath WASM load error + GitHubAPIURL default fallback
TestNew_InvalidDIFCMode difcParseErr != nil warning branch (lines 104-106)
TestHandler_ServesRequests Handler() constructor + verifies /health response

TestHandler_ServesRequests reuses the existing newTestServer helper from handler_test.go (a NoopGuard-based server), so no WASM file is needed. The test routes a real /health request through the wrapped handler to confirm it responds correctly.

Coverage Before / After

Function Before After
proxy.go:New 0.0% 64.0%
proxy.go:Handler 0.0% 100.0%
Package total 92.7% 94.9%

The remaining gap in New (36%) covers the full success path which requires loading a real WASM guard module — not feasible in unit tests.

Test Output

=== RUN   TestNew_EmptyWasmPath
--- PASS: TestNew_EmptyWasmPath (0.00s)
=== RUN   TestNew_InvalidWasmPath
--- PASS: TestNew_InvalidWasmPath (0.00s)
=== RUN   TestNew_InvalidDIFCMode
--- PASS: TestNew_InvalidDIFCMode (0.00s)
=== RUN   TestHandler_ServesRequests
--- PASS: TestHandler_ServesRequests (0.00s)
PASS
ok  	github.com/github/gh-aw-mcpg/internal/proxy	0.010s

All existing proxy tests continue to pass (go test -count=3 ./internal/proxy/ — stable across 3 runs).

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • index.crates.io

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "index.crates.io"

See Network Configuration for more information.

Generated by Test Improver · 450.1 AIC · ⊞ 5.6K ·

- TestNew_EmptyWasmPath: covers the WasmPath == "" guard (line 90-92)
- TestNew_InvalidWasmPath: covers WASM load error path + GitHubAPIURL
  default fallback branch (line 95-97)
- TestNew_InvalidDIFCMode: covers difcParseErr != nil warning branch
  (lines 104-106) in New
- TestHandler_ServesRequests: covers Handler() constructor by routing a
  /health request through the returned http.Handler

Coverage improvement for internal/proxy:
  proxy.go:New     0.0% → 64.0%
  proxy.go:Handler 0.0% → 100.0%
  package total    92.7% → 94.9%

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox lpcox marked this pull request as ready for review July 2, 2026 22:28
Copilot AI review requested due to automatic review settings July 2, 2026 22:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds unit test coverage for previously uncovered internal/proxy/proxy.go constructor helpers (New and (*Server).Handler) in the proxy package.

Changes:

  • Added unit tests for New error paths (empty WASM path, invalid WASM path, invalid DIFC mode fallback behavior).
  • Added a unit test that exercises (*Server).Handler() end-to-end by routing a /health request through the returned handler.
Show a summary per file
File Description
internal/proxy/proxy_server_test.go New tests covering proxy.New early failure branches and Server.Handler() behavior via /health.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Low

@lpcox lpcox merged commit 86e5f0a into main Jul 2, 2026
23 checks passed
@lpcox lpcox deleted the test-improver/proxy-new-handler-coverage-8b1116335cd98991 branch July 2, 2026 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants