Skip to content

test(metrics): cover validate-metrics optional-section branches - #263

Open
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-validate-metrics-branches
Open

kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-validate-metrics-branches

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds 14 fixture-driven cases to tests/validate-metrics.test.mjs covering scripts/validate-metrics.mjs validation outcomes that were never exercised:

  • metric with an absent id, and metric with a null value
  • empty metrics array (accepting path)
  • omitted entry missing id
  • lifecycle card with a non-finite value; lifecycle omission missing reason; fully-populated valid lifecycle
  • time series missing sourceUrl; series point with a non-finite value; fully-populated valid series
  • breakdown whose values is not an array; breakdown missing its label; non-finite breakdown value; fully-populated valid breakdown

These are the guards that only run when a metrics file carries the optional referenceArchitectureLifecycle, series, or breakdown sections. data/metrics.json is a generated artifact, so a partially-written regeneration is precisely what they exist to catch.

Each case asserts the specific exit status and the specific validator error string for its branch, and the valid-section cases pin the accepting path, so the tests fail loudly if a guard is removed or its message drifts.

Tests only — no production code is changed. Suite goes from 55 to 69 passing tests (node --test, node v26.8.2), rebased on current main.

Note on the coverage number

The reported branch percentage for scripts/validate-metrics.mjs will not move when these land. tests/helpers.mjs runScriptWithFixtures runs a temp-dir copy of the script in a subprocess, which node --test coverage instrumentation does not attribute back to the repo path. The evidence of added coverage here is behavioral, not a percentage. That measurement limitation is tracked separately and is not something this PR tries to fix.

Related Issue

Closes #262 (merging this adds every test the issue asks for, leaving nothing further for it to track)


Filed by quality agent (hold-gated mode). Human review required.

— hive: agent=quality backend=copilot model=claude-opus-5

…ches

Adds 14 fixture-driven cases to tests/validate-metrics.test.mjs for
validation outcomes that were never exercised: missing/duplicate metric
ids, null metric values, an empty metrics array, omitted entries missing
an id, lifecycle card and omission validation, time-series sourceUrl and
non-finite point values, and breakdown shape, label and value checks.
Each case asserts the specific error string emitted by its branch, and
the valid-section cases pin the accepting path.

Tests only; no production code is changed. Suite goes from 55 to 69
passing tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: kubestellar-hive[bot] <kubestellar-hive@hive.kubestellar.io>
@kubestellar-hive

Copy link
Copy Markdown
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 outreach agent is always held because it publishes project-facing communication.

Hive will automatically remove the hold label once current policy no longer requires a level hold for "quality". If this is an outreach PR, a human must review it and remove the label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] validate-metrics.mjs optional-section validation branches have no unit coverage

0 participants