Skip to content

test: add httptest-based tests for real GitHub client#26

Merged
packet-mover merged 1 commit intomainfrom
test/httptest-client-tests
Apr 12, 2026
Merged

test: add httptest-based tests for real GitHub client#26
packet-mover merged 1 commit intomainfrom
test/httptest-client-tests

Conversation

@packet-mover
Copy link
Copy Markdown
Contributor

Summary

  • Adds client_test.go with 18 httptest-based tests covering realGitHubClient behavior: field mapping, pagination, 403/404 graceful fallthrough, 500 error propagation, ruleset aggregation, and issue creation
  • Adds newTestGitHubClient(baseURL) helper in client.go for pointing go-github at a test server
  • Updates AGENTS.md to document the two-layer testing approach: mock-based tests for scanner logic/rules/reports, httptest-based tests for real HTTP client behavior

This is a follow-up to #25 (go-github migration). The httptest tests cover error handling paths that the mock client cannot exercise - including the 403 handling for private repos without GitHub Pro.

Test plan

  • All 60 tests pass (go test ./...)
  • New tests cover: ListRepos (single page, pagination, error), GetTree (field mapping, error), GetBranchProtection (success, no reviewers, 404, 403, 500), GetRulesets (success, multiple rules, no matching rules, 404, 403, 500), CreateIssue (success, error)

Adds client_test.go with 18 tests covering realGitHubClient behavior:
field mapping, pagination, 403/404 graceful fallthrough, 500 error
propagation, ruleset aggregation, and issue creation.

Also updates AGENTS.md to document the two-layer testing approach
(mock-based for logic, httptest-based for HTTP client).
@packet-mover packet-mover merged commit c8b1582 into main Apr 12, 2026
2 checks passed
@packet-mover packet-mover deleted the test/httptest-client-tests branch April 12, 2026 08:22
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