Skip to content

test(mock): the mock must serve every base the plugin can produce - #142

Merged
viztor merged 1 commit into
mainfrom
test/mock-coverage
Oct 31, 2026
Merged

viztor merged 1 commit into
mainfrom
test/mock-coverage

Conversation

@viztor

@viztor viztor commented Oct 31, 2026

Copy link
Copy Markdown
Owner

The coverage invariant behind every offline case.

The request-shape and plugin suites assert what a request looks like. If the plugin starts sending to a base this server does not serve, the answer is 404 no_route — and a case that checks the headers rather than the status passes anyway. So a base the plugin knows and the mock does not is a hole in the whole suite, and it is silent.

The bases come from the plugin's own constants — OPENCODE_PLANE_API, LEGACY_PLANE_API, OPENCODE_FAMILY_API, DEFAULT_USAGE_BASE_URL — so a vendor move that adds a family fails here rather than in a case that happens not to look.

The first version of this test proved nothing

Worth recording, because it is the exact failure this suite exists to catch: it fetched the constants as given — absolute URLs on opencode.ai — so it left the machine, asked the real gateway, and passed while the mock went untouched.

The mock suite is supposed to be offline; a probe that reaches the internet is both a lie and a flake. It now takes the plugin's path and the mock's origin.

Verification

Planted a missing family root:

FAIL test/mock/gateway-contract.mock.ts > serves every base URL the plugin can produce
AssertionError: bases the plugin can send to and the mock cannot serve:
  expected [ 'https://opencode.ai/zen/go/v1' ] to deeply equal []

…while the matrix suite (protocol-compat.mock.ts) catches the same hole from the other side — the exercised plane × protocol × family combinations. The two together close it.

gate result
mock suite 52 passed (+1)
unit suite 1210 passed / 80 files
vp check 0 errors

The coverage invariant behind every offline case. The request-shape and plugin
suites assert what a request LOOKS like; if the plugin starts sending to a base
this server does not serve, the answer is `404 no_route` — and a case that
checks the headers rather than the status passes anyway. So a base the plugin
knows and the mock does not is a hole in the whole suite, and it is silent.

The bases come from the plugin's own constants (`OPENCODE_PLANE_API`,
`LEGACY_PLANE_API`, `OPENCODE_FAMILY_API`, `DEFAULT_USAGE_BASE_URL`), so a
vendor move that adds a family fails here rather than in a case that happens
not to look.

**The first version of this test proved nothing, and that is worth recording.**
It fetched the constants AS GIVEN — absolute URLs on `opencode.ai` — so it left
the machine, asked the real gateway, and passed while the mock went untouched.
The suite is supposed to be offline; a probe that reaches the internet is both
a lie and a flake. It now takes the plugin's PATH and the mock's origin.

Planted a missing family root, it fails with the base named; the matrix suite
catches the same hole from the other side (the exercised combinations), so the
two together close it.
@viztor
viztor merged commit a49dc7f into main Oct 31, 2026
3 checks passed
@viztor
viztor deleted the test/mock-coverage branch October 31, 2026 17:35
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