Repository navigation
test: unit tests for pkg/api core handlers (api.go) — 13.1% → 39.4% [quality] - #137
Conversation
Direct unit tests for the previously 0%-covered pkg/api/api.go handler cluster: idea CRUD authorization (private-idea 404 non-leak, offer-based reveal, author-only writes), admin gating via DIBS_ADMINS, the async admin rematch lifecycle (dry run -> poll -> apply -> stale re-apply), request-body limits, repo registry scopes, and the pure helpers. pkg/api coverage: 13.1% -> 39.4%. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check <sec-check@hive.kubestellar.io>
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the Hive will automatically remove the |
|
[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 |
Test Improvement
Adds
pkg/api/api_test.go— direct unit tests for the previously 0%-covered core handler cluster inpkg/api/api.go:loadAuthorized,offeredToCallerRepo,handleGetIdea/handleUpdateIdea/handleDeleteIdea): private ideas 404 (not 403) to strangers so their existence doesn't leak; offers reveal a private idea to the target repo's owner only; writes are author-only even on public ideas.requireAdmin,handleAdminIdeas,handleAdminRematch*): DIBS_ADMINS gating (incl. anonymous), admin listing with provider fallback, engine-absent 503, unknown-idea 404, stale-job 409.since/jobparams → apply persists reviewed results → consumed dry run refuses re-apply (409).decodeInput): invalid JSON 400, oversized body 413; client-settable status restricted to draft/offered on create and update.handleListIdeas(mine/public/invalid,SuggestionsSeenAtscrubbed for non-authors),handleListRepos(accepting/all/mine/invalid),handleUpdateRepo(owner-only, 404/403).firstNonEmpty,ideaForViewer(no mutation of the original),summarizeMatchestop-3 cap,responseSince,storeErrStatus.Hermetic: temp-dir store/registry, identity injected via
auth.WithIdentity, admin viat.Setenv, nil-LLM engine uses the deterministic fallback matcher.pkg/apicoverage: 13.1% → 39.4%. Fullgo test ./...green; async tests stable at-count=5. (Local run without-race: no cgo toolchain on this host; handlers guard shared state withrematchMu.)Files claimed:
pkg/api/api_test.go(new, tests only — no production code changes). Disjoint from open PRs pluk#43 (Dependabot config) and hotshot#34 (install.sh tests).Related Issue
Refs #136 (partial fix: covers the api.go cluster; wave2/settlement/market/wave3 handlers remain untested and are tracked there)
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-fable-5 copilot=1.0.88