Repository navigation
test(booking): assert persisted state and fail on leaked cleanup - #3
Merged
Merged
Conversation
… cleanup PUT, PATCH and the invalid-token write only checked the response, so a server that echoed the body without saving it passed. They now read the booking back. The malformed-create test pins the documented 500 and checks nothing was stored, with a valid booking under the same name proving the filter works. The list contract test now looks for a booking it just created. Missing credentials now get the same failure-schema check as bad credentials. cleanup() swallowed failed deletes and leaked bookings onto the shared demo. It now fails teardown and names the bookings it could not remove.
VincentJerico
force-pushed
the
test/assert-persisted-state
branch
from
September 29, 2026 00:37
aa0749f to
9e734fd
Compare
cleanup() treated a 404 on DELETE as "already gone", but Restful-Booker answers DELETE on a missing booking with 405 (GET returns 404). A booking wiped by the demo API's periodic reset therefore made cleanup throw and fail the test in teardown with no real leak. When DELETE doesn't succeed, cleanup now asks GET: 404 means gone, anything else still counts as leaked. Adds a regression test that deletes a booking behind the client's back and requires cleanup() to succeed. It failed before this change with "cleanup could not delete bookings: <id>".
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.
Why
Run against a local Restful-Booker mock with each defect below switched on, the suite still passed 16/16:
GET /bookingreturned[]. The list contract accepts an empty list.cleanup()swallowed that and leaked 9 bookings, which contradicts the README's promise that tests never leak data.Scope
issueannotation. It then proves nothing was stored by creating a valid booking under the same unique name and asserting the name filter returns only that booking..nonempty(), which would depend on other users' data.BookingClient.cleanup()throws after the loop if any booking it created is still there. When a DELETE fails, a GET decides: Restful-Booker answers DELETE on a missing booking with 405, not 404, so the status code alone can't tell.cleanup()to succeed.list()takes an optional{ firstname }filter.Verification
mainand turns its test red on this branch. The cleanup defect fails with "cleanup could not delete bookings".cleanup()throw.