Assert what a failure carries rather than inspect it - #11
Merged
Conversation
The error model promises three things on every condition: the GQLSTATUS code, the place in the statement, and the page that documents it. Two of the three were untested here, and the third was tested in a way that could not fail. The position test read `e.position().ifPresent(p -> assertTrue(...))`, which passes when there is no position at all. So did the caret. That is the shape of assertion that turns a suite into a page of promises with a green tick on it: the one outcome worth failing for is the one it lets through. Where a field is genuinely optional now, the case that has it and the case that does not are two tests and each says which it is. The doc URL was never checked anywhere. It is the field a program hands a reader instead of five characters to go and search for, and it is now asserted to be the base plus the code exactly as the code is written. Exactly, because a condition class can have a letter in it and a URL that lower cased it would be a 404 nobody would notice until somebody clicked it. Added with it: that the offset is where the token starts and a caller who still has the text can slice at it, that the caret sits under the column, that a name nothing bound is 42002 and not merely something in class 42, that a connection used after close carries the misuse status and deliberately carries no code and no page because it never reached the engine, that a database that is not there names the path it looked for, that the condition classes are subclasses of the one, and that a diagnostic for a call that never happened leaves every field empty rather than filling it with a zero that reads like a place in the text. Thirteen cases, run twice, once on each provider. Green on both against libzu at the engine's HEAD.
tamnd
added a commit
to tamnd/zu
that referenced
this pull request
Aug 22, 2026
The row said zero on all ten items, which was not an audit. It was a row nobody had filled in, and a scorecard with a placeholder in it is worse than one with a gap, because the placeholder reads like a measurement. Audited, zu-java held two of them already. reference, because the javadoc is generated and published with the release rather than written by hand beside it, and CI builds it on every push so it cannot rot quietly. idiom, because the API is records, a sealed Value, AutoCloseable on every handle, Stream<Row> for iteration, text blocks in the examples and unchecked exceptions with a retryable field rather than a checked one on every signature. conditions is the third and it landed today, tamnd/zu-java#11. The code, the place and the doc URL are asserted on every failure that has them and asserted absent on the failures that do not, which is the part the old test could not do. 35 of 90. quickstart, misuse, leaks, install and stability are the apparatus still to build, and api-map and perf are reports.
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.
The
conditionsitem of the practice scorecard, which reads: every failure carries the standard's condition code, the place, and the doc URL, checked by a test rather than promised in a page.Two of the three were not checked here, and the third was checked in a way that could not fail.
The assertion that passes when the field is missing
That is green when there is no position. So was the caret assertion beside it. The one outcome worth failing for is the one it lets through, and a suite with a few of these in it stops being evidence.
Where a field is genuinely optional the case that has it and the case that does not are now two tests, and each one says which it is. A syntax error has a position and the test asserts it. A connection used after close has none, and the test asserts that too, because a misuse that borrowed a condition code would send a reader to a page about something else.
The doc URL
Never checked anywhere. It is now asserted to be the base plus the code exactly as the code is written:
Exactly, because a condition class can have a letter in it,
01G11for one, and a URL that lower cased the code would be a 404 that nobody notices until somebody clicks it.What else went in
^42002and not merely something in class 42MISUSE_CLOSED, no code and no page, deliberatelyChecked
On a server, against
libzubuilt from the engine at HEAD.mvn test -pl zudb-ffm -am -Dtest=ErrorTest: 13 of 13mvn test -pl zudb-jni -am -Dtest=ErrorTest: 13 of 13, same cases through the other providermvn testover the whole reactor: build success, every module green, both providersThis takes zu-java from 25 to 35 of 90 on practice. The two items it already held and nobody had recorded are
reference, since the javadoc is generated and published with the release, andidiom, since the API is records, a sealedValue,AutoCloseableon every handle,Stream<Row>and unchecked exceptions. The scorecard said zero for all ten, which was never an audit, only a row nobody had filled in.