Repository navigation
test: add unit coverage for pipelines_client.go fetch wrappers - #24019
Conversation
fetchRuns, fetchWorkflowRuns, and fetchJobs in pkg/api/handlers/github/pipelines_client.go were at 0% unit coverage (go-test.yml run 37222865140) despite backing every view on the /ci-cd pipeline dashboard. Add tests using the existing RoundTripFunc HTTP-mock pattern already in this package, covering success/decode, 404-is-empty, >=400-is-error, malformed JSON, and fetchRuns' multi-page aggregation up to ghpMaxPages. Signed-off-by: quality <quality@hive.kubestellar.io>
✅ Deploy Preview for kubestellarconsole canceled.
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
👋 Hey @hivecommons-hive[bot] — thanks for opening this PR!
This is an automated message. |
There was a problem hiding this comment.
Read the tests against the implementations in pkg/api/handlers/github/pipelines_client.go at this head (06c9ddc). The cases match the actual code paths: fetchWorkflowRuns returns nil, nil on 404 (pipelines_client.go:198-200), fetchRuns treats 404 as done via ghpDecodeWorkflowRuns (pipelines_client.go:168-170) and paginates with pageSize capped at ghpMaxPerPage (pipelines_client.go:110-116) — the 250→3×100-page test exercises that correctly. Transport errors bypass the rate-limit retry in ghGetWithRetry (pipelines_client.go:64-66), so the error tests are fast. Helpers reuse the existing RoundTripFunc without symbol collisions, and CI's go test ./... is green on this head. Looks correct to me.
One minor note (not a defect): the comment in TestFetchRuns_SinglePageUnderPageSize says a short page "signals the last page, so fetchRuns must not issue a second request", but with per_page=10, maxPages computes to 1 (pipelines_client.go:113), so the loop could never issue a second request regardless — the len(runs) < pageSize short-circuit at pipelines_client.go:138 is not actually what that test exercises. Worth fixing the comment (or using a query that yields maxPages > 1) if this PR is touched again; fine to merge as is.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
|
Post-merge build verification passed ✅ Both Go and frontend builds compiled successfully against merge commit |
✅ Post-Merge Verification: passedCommit: |
Test Improvement
Adds unit tests for
fetchRuns,fetchWorkflowRuns, andfetchJobsinpkg/api/handlers/github/pipelines_client.go, which were at 0% coverage(see linked issue for the CI-artifact evidence). Uses the existing
RoundTripFuncHTTP-mock helper already present in this package(
pipelines_client_test.go) — no new test infrastructure.Cases covered per function: success/decode,
404-treated-as-empty,>=400-is-error, malformed-JSON, transport error, and (forfetchRuns)pagination across multiple full pages up to
ghpMaxPages.Verified with
go buildagainst a renamed-to-.gocopy of the test filein a scratch package (
go test/go vetare disabled for agents in thisenvironment); this PR's own CI run is the first real test execution.
Closes #24018
Filed by quality agent (ACMM L4/L6 — full mode)
— hive: agent=quality backend=copilot model=claude-opus-4.7 copilot=1.0.88