Skip to content

test: consolidate the contract-test infrastructure (#34) - #35

Merged
Blind-Striker merged 5 commits into
masterfrom
test/m2-contract-test-consolidation
Aug 15, 2026
Merged

Blind-Striker merged 5 commits into
masterfrom
test/m2-contract-test-consolidation

Conversation

@Blind-Striker

Copy link
Copy Markdown
Collaborator

Closes #34 (second-review finding R2-15).

What

  • One shared support pair. FixtureLoader, RecordingHttpHandler, and RecordedRequest now live in tests/Shared/ and compile into both OpenCode.Sdk.Tests and OpenCode.Sdk.Extensions.Tests via <Compile> links — no new project, no IVT change, no Sonar test-probe exposure. The unified handler is the SDK superset (full RecordedRequest recording, IsDisposed) plus the Extensions RespondingJson convenience; the loader derives its resource prefix from the compiling assembly's name so each project keeps its own Fixtures/ layout.
  • One contract scaffold. The Endpoint/CreateClient/JsonResponse trio that was copy-pasted verbatim across the three contract-test classes is replaced by ContractScenario (client-over-recording-transport assembly, Client/Requests exposure, disposable), per testing-style §1.
  • Wire bodies out of inline literals. WireBodyData centralizes the recurring error bodies and the {"data":…} envelope / cursor-page shapes; literals that are themselves the subject under test stay inline per testing-style §3.
  • The missing observation. GetSessionAsync_Should_Treat_A_Null_Datum_As_A_Protocol_Failure pins the object-envelope {"data":null} refusal the review verified as working-but-unobserved.

Scope notes

Verification

All six gates green at every commit (slopwatch → build → format → tooling smoke → generate --verify → tests); 935 tests (932 + the new observation on three local legs). The net472 legs compile on the Windows CI lane only — the shared files use the same Polyfill-covered surface the deleted SDK copies already compiled there.

…K and Extensions test projects

The Extensions copies were a namespace-only byte-copy (FixtureLoader) and a
divergent same-named twin (RecordingHttpHandler). Both now compile from a
tests/Shared source folder linked into each test project; the unified handler
records full RecordedRequest entries and keeps the RespondingJson convenience,
and the loader derives its resource prefix from the compiling assembly's name.
The Endpoint/CreateClient/JsonResponse trio was copy-pasted verbatim across the
three contract-test classes, and the recurring error/envelope literals repeated
across methods and files. ContractScenario now owns client-over-recording-
transport assembly and WireBodyData carries the canned bodies plus the
data-envelope and cursor-page shapes; one-off literals that are themselves the
subject under test stay inline.
The second review verified {"data":null} on the object envelope refuses as a
protocol failure but found no test observing it; the list-envelope twin was the
only pinned case.
The InvalidCursorError/InvalidRequestError bodies join WireBodyData (the
400-pair test rides the constants through its Arguments rows), the undeclared-
status test reuses the canned UnauthorizedError body, and RespondingJson guards
its body at the factory boundary.
@Blind-Striker
Blind-Striker merged commit b3384ed into master Aug 15, 2026
3 checks passed
@Blind-Striker
Blind-Striker deleted the test/m2-contract-test-consolidation branch September 14, 2026 12:55
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.

M2: contract-test infrastructure consolidation — shared scaffold, single Support classes (R2-15)

1 participant