Skip to content

[test] Add tests for proxy.MatchRoute uncovered route patterns#3115

Merged
lpcox merged 1 commit intomainfrom
test/add-router-uncovered-routes-coverage-9719cd86afff5001
Apr 5, 2026
Merged

[test] Add tests for proxy.MatchRoute uncovered route patterns#3115
lpcox merged 1 commit intomainfrom
test/add-router-uncovered-routes-coverage-9719cd86afff5001

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 3, 2026

Test Coverage Improvement: proxy.MatchRoute

Function Analyzed

  • Package: internal/proxy
  • Function: MatchRoute (in router.go)
  • Previous Coverage: Several route patterns completely untested
  • New Coverage: 17 additional test cases covering 9 previously-untested route categories
  • Complexity: High (50+ route patterns defined via data-driven route table)

Why This Function?

MatchRoute is the central REST routing function — every GitHub API request flows through it to determine which DIFC guard tool to apply. Several route categories added to the route table (router.go) had no corresponding tests in proxy_test.go or proxy_coverage_test.go, creating blind spots in route correctness verification.

Tests Added

The new file internal/proxy/router_uncovered_routes_test.go adds TestMatchRoute_UncoveredRoutes with 17 table-driven test cases covering:

  • Environment-scoped Actions/repos/{owner}/{repo}/environments/{env}/secrets and .../variableslist_environment_config
  • Org-scoped Actions/orgs/{org}/actions/secrets, .../variables, and .../variables/{name}list_org_config
  • Individual discussion/repos/{owner}/{repo}/discussions/{number}list_discussions with discussion_number
  • Discussion comments/repos/{owner}/{repo}/discussions/{number}/commentsget_discussion_comments
  • Commit check-suites/repos/{owner}/{repo}/commits/{sha}/check-suitespull_request_read (same tool as check-runs)
  • User SSH signing keys and GPG keys/user/ssh_signing_keys, /user/gpg_keysget_me
  • Named Actions variable/repos/{owner}/{repo}/actions/variables/{name}list_variables
  • Query string stripping — uncovered route with ?per_page=30 suffix
  • Nil returns — 5 paths that match no route (/unknown-path, /search/users, /repos, /repos/only-owner, /orgs/myorg/members)

Coverage Improvement

Each new test case exercises a distinct code path (route pattern match) in the route table. The nil-return tests also exercise the "no match" branch of MatchRoute's loop which previously had no test coverage.

Test Pattern

Tests follow the established table-driven pattern in the codebase (proxy_test.go, proxy_coverage_test.go), using testify/assert and testify/require for consistent assertion style.


Generated by Test Coverage Improver
Next run should target: environment-scoped and org-scoped route patterns in handler tests, or callBackendTool DIFC propagate-mode edge cases

Generated by Test Coverage Improver ·

Cover 17 route patterns that were not exercised by existing tests:

- Environment-scoped Actions secrets and variables (list_environment_config)
- Org-scoped Actions secrets, variables, and named variable (list_org_config)
- Individual discussion (list_discussions with discussion_number)
- Discussion comments (get_discussion_comments)
- Commit check-suites (pull_request_read, same tool as check-runs)
- User SSH signing keys and GPG keys (get_me)
- Actions variable accessed by name (list_variables optional suffix)
- Query string stripping for uncovered routes
- Paths that match no route (nil return)

Co-authored-by: Copilot <[email protected]>
@lpcox lpcox marked this pull request as ready for review April 5, 2026 22:07
Copilot AI review requested due to automatic review settings April 5, 2026 22:07
@lpcox lpcox merged commit 3c26d2a into main Apr 5, 2026
3 checks passed
@lpcox lpcox deleted the test/add-router-uncovered-routes-coverage-9719cd86afff5001 branch April 5, 2026 22:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 improves test coverage for internal/proxy.MatchRoute, the central REST routing function used to map GitHub API paths to DIFC guard tools.

Changes:

  • Added a new table-driven test suite covering previously untested REST route patterns (env-scoped Actions config, org-scoped Actions config, discussion detail/comments, check-suites, user key endpoints).
  • Added explicit “no route match” cases to exercise the nil-return branch.
  • Added an additional query-string case to validate query stripping for an uncovered route category.
Show a summary per file
File Description
internal/proxy/router_uncovered_routes_test.go Adds 17 new table-driven MatchRoute test cases to cover previously uncovered route patterns and nil-return behavior.

Copilot's findings

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

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