test: add test harness + suite (incl. #4 concurrency regression) #10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/tests-harness"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stands up a
tests/harness for chatelet and covers the money paths, including a real regression for the #4 atomic-hold fix.What's here
pyproject.toml,Makefile) — poetry/pytest/ruff/black/mypy config mirroring the aio lint pipeline (spirekeeper template).make test,make check.crud/create_invoice, drive async withasyncio.run— no live DB or wallet):test_availability— half-open overlap semantics (back-to-back stays don't collide),is_availableblocking on held/confirmed bookings + manual blocks, cancelled bookings freeing dates.test_booking_flow— canonicalamount_sat,held → awaiting_payment, min-nights guard, and hold-release (declined) onInvoiceError.test_atomic_hold— the #4 regression: two concurrent same-date requests → exactly one hold + oneUnavailable; two non-overlapping requests on the same room both succeed.The concurrency test genuinely guards the fix
The fakes
await asyncio.sleepbetween reading availability and committing the hold, opening the exact race window the per-room lock closes. Verified locally:16 passed.BookingQuotes (double-booking) — confirming the test fails without the fix.Notes
.venvby symlinking the extension intolnbits/extensions/(removed after). CI/make testruns it in the same env._reset_room_locksfixture: each test uses its ownasyncio.runloop, and the module-level lock registry would otherwise carry a lock bound to a closed loop. Production is unaffected (one long-lived loop).Why PR
Consistency with the repo's flow; handing off merge to you via the Forgejo UI.
🤖 Generated with Claude Code