test(collectors): cover the six uncovered sub-line fallback regions - #693
Closed
hivecommons-hive[bot] wants to merge 1 commit into
Closed
hivecommons-hive[bot] wants to merge 1 commit into
hivecommons-hive[bot] wants to merge 1 commit into
Conversation
The three data collectors each report 100% line coverage while six sub-line regions never execute: line coverage marks a line covered when any character on it ran, so a || default or a ternary arm that never executed stays invisible whenever the rest of its line did run. Covered here: - collect-metrics.mjs:39 source.landscape || [] - collect-metrics.mjs:41 subcategory.items || [] - collect-metrics.mjs:45 category.name || 'Other' - collect-radar-reports.mjs:52 existing.radarReports || [] - collect-launch-metrics.mjs:142 githubAll Authorization ternary, both arms The Authorization pair needed a new capability rather than a new fixture: the sandbox pins GH_TOKEN='' for reproducibility and had no way to observe outbound request headers, so no test could assert what a collector sends. runScriptInSandbox now logs every stubbed fetch and returns it as `requests`, which lets the token and no-token cases both be asserted directly instead of inferred from the response handling. Source region coverage rises from 97.95% to 98.26%; all 1186 unit tests pass. Closes #692 Signed-off-by: hivecommons-hive[bot] <hivecommons-hive@hive.kubestellar.io>
Contributor
Author
|
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 |
This was referenced Sep 26, 2026
Closed
Member
|
Superseded by #750, which consolidates this and 14 other test-only coverage PRs into a single reviewable change (commit cherry-picked unmodified, authorship and DCO preserved). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test Improvement
Closes the six uncovered sub-line regions in the three data collectors. Each
file already reported 100.00% line coverage, so these gaps were invisible
there: line coverage marks a line covered when any character on it ran, and a
||default or a ternary arm that never executed hides behind the rest of itsline.
scripts/collect-metrics.mjssource.landscape || []scripts/collect-metrics.mjssubcategory.items || []scripts/collect-metrics.mjscategory.name || 'Other'scripts/collect-radar-reports.mjsexisting.radarReports || []scripts/collect-launch-metrics.mjsgithubAllAuthorization ternary, both armsFiles touched
tests/helpers-script-sandbox.mjs— thegithubAllAuthorization pairneeded a new capability, not a new fixture. The sandbox pins
GH_TOKEN: ''so runs stay reproducible, and it had no way to observe outbound request
headers, so nothing in the repository could assert what a collector actually
sends. The stubbed
fetchnow appends{url, headers}to a per-run log andrunScriptInSandboxreturns it asrequests. No existing caller changesbehaviour; the field is additive.
tests/collect-metrics.test.mjs— three cases: alandscape.ymlwith nolandscape:key, a subcategory declaring no items, and an unnamed categoryfalling back to the
Otherbucket.tests/collect-radar-reports.test.mjs— one case: an existing catalog filewith no
radarReportskey is treated as empty rather than crashing therefresh.
tests/collect-launch-metrics.test.mjs— two cases asserting onrequests:the credential reaches every paginated collection request when
GH_TOKENisset, and no
Authorizationheader is sent when it is not.No production code is touched.
Verification
TZ=UTC node tests/tools/coverage-report.mjs, before → after:1186 unit tests pass, 0 fail.
collect-metrics.mjsstops at 98.89% rather than 100% because of a seventhregion no test can reach:
clone(url, destination, shallow = false)atL156-160 is module-internal and both call sites (L22, L23) pass
true, so the: []arm and theshallow = falsedefault are dead code. Removing them is aproduction-code change and is deliberately left out of this PR; it is recorded
under "Out of scope" on the issue.
Disjointness
This PR claims
tests/helpers-script-sandbox.mjsplus thecollect-metrics/collect-radar-reports/collect-launch-metricstestfiles. That is disjoint from every open hold-gated PR: #678 claims
tests/helpers-import-sandbox.mjsandimport-architectures, #680 claimssvg-active-content, #686 claimsfetch-community-people, #688 claims thefour
validate-*test files, and #674 claimspackage.json.Related Issue
Closes #692
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88