You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
openapi: two schema composition tests assert less than their names claim #742
Two tests in compilers/openapi/internal/schema/compose_test.go cannot fail for the reason they were written.
TestUnionCombinators_CoDeclaredKeepsTheBoundsWrittenBesideIt declares a wantDiag column and, after its other assertions, checks that the openapi/degraded-construct diagnostic at /components/schemas/A contains it. No case sets wantDiag, so every case returns before that check. The last case that set it ("kept minimum as the tighter of the two", added in fix(compilers/openapi): keep bounds beside a preserved union #363) was removed in feat(ir)!: land the IR 0.4.0 stack #464, which left the column and the branch in place.
TestAllOf_BoolBranchSkippedInCompositionRequired exercises the bs == nil guard in compositionRequired (compose.go), which skips an allOf branch that is a bare boolean schema. The guard has no observable effect: GetRequired is nil-safe, so without it the loop appends nothing for that branch either. Deleting the guard leaves the package green.
prints the field, the if tc.wantDiag == "" early return and the assert.Contains, and no case literal.
For the guard, delete the three lines of if bs == nil { continue } in compositionRequired and run:
$ go test ./compilers/openapi/internal/schema/ -count=1ok github.com/dexpace/morphic/compilers/openapi/internal/schema
Why it matters
The wantDiag column reads as coverage of what reading the co-declared bounds reports, and nothing checks it. A change that stops reporting, or reports the wrong thing, passes.
The guard is harmless, but it is the only reason the bool-branch test's name points at compositionRequired: the test pins the lowered result, which holds with or without it.
Options
Give the union-combinators table a case that sets wantDiag to what the bounds reading reports today, or drop the column and the branch if it reports nothing worth pinning.
Delete the guard, since the code reads the same without it, or keep it and name the test for the behaviour it pins.
Problem
Two tests in
compilers/openapi/internal/schema/compose_test.gocannot fail for the reason they were written.TestUnionCombinators_CoDeclaredKeepsTheBoundsWrittenBesideItdeclares awantDiagcolumn and, after its other assertions, checks that theopenapi/degraded-constructdiagnostic at/components/schemas/Acontains it. No case setswantDiag, so every case returns before that check. The last case that set it ("kept minimum as the tighter of the two", added in fix(compilers/openapi): keep bounds beside a preserved union #363) was removed in feat(ir)!: land the IR 0.4.0 stack #464, which left the column and the branch in place.TestAllOf_BoolBranchSkippedInCompositionRequiredexercises thebs == nilguard incompositionRequired(compose.go), which skips anallOfbranch that is a bare boolean schema. The guard has no observable effect:GetRequiredis nil-safe, so without it the loop appends nothing for that branch either. Deleting the guard leaves the package green.Reproduction
$ git grep -n 'wantDiag' -- compilers/openapi/internal/schema/compose_test.goprints the field, the
if tc.wantDiag == ""early return and theassert.Contains, and no case literal.For the guard, delete the three lines of
if bs == nil { continue }incompositionRequiredand run:Why it matters
The
wantDiagcolumn reads as coverage of what reading the co-declared bounds reports, and nothing checks it. A change that stops reporting, or reports the wrong thing, passes.The guard is harmless, but it is the only reason the bool-branch test's name points at
compositionRequired: the test pins the lowered result, which holds with or without it.Options
wantDiagto what the bounds reading reports today, or drop the column and the branch if it reports nothing worth pinning.