Skip to content

test: add a coverage floor, and cover the server and upgrade paths - #52

Merged
titouanmathis merged 1 commit into
mainfrom
test/coverage-gate
Sep 7, 2026
Merged

test: add a coverage floor, and cover the server and upgrade paths#52
titouanmathis merged 1 commit into
mainfrom
test/coverage-gate

Conversation

@titouanmathis

Copy link
Copy Markdown
Contributor

The floor

test:ci now fails when coverage drops below a threshold set just under the current numbers — a regression fails, an improvement doesn't.

Verified it actually bites, rather than passing silently:

ERROR: Coverage for statements (76.24%) does not meet global threshold (99%)
exit code: 1

This is the gate for the problem behind several fixes this cycle: loadProjectList and routePath each had no tests and each hid a bug for nine releases.

statements branches functions lines
agent floor 75 70 70 75
agent actual 76.24 71.37 70.66 76.87
CLI floor 95 92 100 95
CLI actual 97.02 93.06 100 97

Reaching a floor worth having

server.ts: 5.8% → 66.7%. The handlers take a ServerDeps seam holding the project index, the per-project configs and the side effects, so a test drives them with a known world and records what they did — no socket, no database, no DDEV install.

The cases are about decisions, not plumbing:

  • a project's own auth_policy overrides the global one, while credentials stay server-wide
  • a second request during a start does not queue another ddev start
  • a failed start records stopped rather than leaving the project wedged on starting
  • /__auth__?s=term reaches the auth handler — the query-string routing bug from 0.1.33, now pinned down

setup/upgrade.ts: 18.9% → 66.7%. runUpgrade takes an UpgradeIo, which is what makes the re-exec path testable without replacing the process. The two guards worth covering are both loops:

  • no re-exec when npm served a stale cache and left the old version in place
  • no second re-exec once one has happened

Plus: an unreachable registry must not stop migrations that are already due.

Notes

Agent overall 66.8% → 76.2%. 474 tests, no mocks — the new fakes follow the injection convention from #51.

The floors are deliberately a ratchet, not a target. server.ts still has uncovered startup plumbing and upgrade.ts its process-level helpers; raise the numbers as those get covered.

The floor is the point. Two untested parsers, loadProjectList and
routePath, each hid a bug for nine releases; a threshold is what stops
the next one. Set just under the current numbers so a drop fails CI while
an improvement does not, and verified to actually fail rather than pass
silently — raising the bar above the current figure exits 1.

Reaching a floor worth having meant covering the two big holes.

server.ts was at 5.8%. The handlers now take a ServerDeps seam holding
the project index, the per-project configs and the side effects, so a
test drives them with a known world and records what they did: no socket,
no database, no DDEV install. That covers the decisions rather than the
plumbing — a project's own auth_policy overriding the global one while
credentials stay server-wide, a second request during a start not
queueing another ddev start, a failed start recording "stopped" instead
of leaving the project wedged on "starting", and /__auth__?s=term
reaching the auth handler, which is the query-string routing bug from
0.1.33 now pinned down.

setup/upgrade.ts was at 18.9%. runUpgrade takes an UpgradeIo, which is
what makes the re-exec path testable without replacing the process. The
two guards worth having tests are both loops: no re-exec when npm served
a stale cache and left the old version in place, and no second re-exec
once one has happened.

Agent coverage 66.8% -> 76.2%, server.ts 5.8% -> 66.7%, upgrade.ts
18.9% -> 66.7%. The CLI was already at 97%.

Co-authored-by: Claude <claude@anthropic.com>
@titouanmathis
titouanmathis merged commit 2337850 into main Sep 7, 2026
4 of 5 checks passed
@titouanmathis
titouanmathis deleted the test/coverage-gate branch September 7, 2026 22:12
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.12%. Comparing base (46241f0) to head (e71bb19).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
packages/trafic-agent/src/server.ts 84.00% 4 Missing ⚠️
packages/trafic-agent/src/setup/upgrade.ts 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #52      +/-   ##
==========================================
+ Coverage   75.42%   82.12%   +6.70%     
==========================================
  Files          35       35              
  Lines        1461     1466       +5     
  Branches      373      374       +1     
==========================================
+ Hits         1102     1204     +102     
+ Misses        292      219      -73     
+ Partials       67       43      -24     
Flag Coverage Δ
integration 65.74% <ø> (ø)
unit 81.92% <84.61%> (+6.70%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

titouanmathis added a commit that referenced this pull request Sep 8, 2026
`test:integration:ci` collects coverage for Codecov's `integration` flag, so
it inherited the thresholds from vite.config.ts. Those are the unit suite's
floor; the integration suite exercises ssh.ts against a real SSH server and
touches little else, so it reports 66% and the run failed with all of its
tests passing. CI has been red on main since 0.1.39 was released — the gate
from #52 was measuring the wrong suite.

Also adds the regression test for the parent-directory bug, against real
rsync in the container. Verified to have teeth: with the fix removed it fails
with the same "change_dir ... failed: No such file or directory" the
deployment hit, and passes with it. 14 integration tests.

Co-authored-by: Claude <claude@anthropic.com>
Claude-Session: https://claude.ai/code/session_016xdQPh3UcnZfjM5HS36ABP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant