Repository navigation
test: consolidate the contract-test infrastructure (#34) - #35
Merged
Merged
Conversation
…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.
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.
Closes #34 (second-review finding R2-15).
What
FixtureLoader,RecordingHttpHandler, andRecordedRequestnow live intests/Shared/and compile into bothOpenCode.Sdk.TestsandOpenCode.Sdk.Extensions.Testsvia<Compile>links — no new project, no IVT change, no Sonar test-probe exposure. The unified handler is the SDK superset (fullRecordedRequestrecording,IsDisposed) plus the ExtensionsRespondingJsonconvenience; the loader derives its resource prefix from the compiling assembly's name so each project keeps its ownFixtures/layout.Endpoint/CreateClient/JsonResponsetrio that was copy-pasted verbatim across the three contract-test classes is replaced byContractScenario(client-over-recording-transport assembly,Client/Requestsexposure, disposable), per testing-style §1.WireBodyDatacentralizes 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.GetSessionAsync_Should_Treat_A_Null_Datum_As_A_Protocol_Failurepins the object-envelope{"data":null}refusal the review verified as working-but-unobserved.Scope notes
FixtureLoaderis a divergent sibling (LoadvsLoadJson, BOM-strip vs newline-trim, known-names diagnostics), outside R2-15's byte-copy finding — left for the Hygiene sweep: reuse, simplification and tooling-performance leftovers (R1-R3, R5, R6, S1-S8, P6, P7) #24 hygiene sweep rather than scope-creeping this PR.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.