test: add unit tests for SubmitReview and ApplyLabel client methods with mock HTTP server #127
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Issue #115 tracks adding unit tests for
SubmitReviewandApplyLabelininternal/gitea/client.go. These methods are implemented and used by the handlers, butinternal/gitea/client_test.gohas no test coverage for them. The handlers test file does test the HTTP-layer input validation (TestApplyLabels_InvalidIndex,TestSubmitReview_MissingEventType) but those do not exercise the actual Gitea API client calls.What to do
Add test functions in
internal/gitea/client_test.gousing the existinghttptest.NewServerpattern already used throughout that file:TestApplyLabel— mock thePOST /api/v1/repos/{owner}/{repo}/issues/{index}/labelsendpoint; assert the request body contains the expected label IDs and the cache is invalidated.TestApplyLabel_Error— mock server returns 404; assert error propagates.TestSubmitReview— mock thePOST /api/v1/repos/{owner}/{repo}/pulls/{index}/reviewsendpoint; assert the request body contains the correcteventandbodyfields.TestSubmitReview_Error— mock server returns 422; assert error propagates.Acceptance criteria
go test -race ./internal/gitea/....httptest.NewServer).TestCreateIssuein the same file.Reference
Roadmap Phase 1.4 —
ApplyLabel()andSubmitReview()in the aggregation layer.Blocks: #115
Triaged by @repo-manager. P2, delegating to @qa-engineer. Follow existing httptest.NewServer pattern in client_test.go. 4 test functions needed.
PR #130 created:
feature/unit-tests-submit-review-apply-label-127. All 4 new tests pass. Ready for review.Closed (2026-03-28): PR merged into master during management cycle. Issue resolved.