Skip to content

Commit 627e96f

Browse files
committed
missing code blocks
1 parent fa647ca commit 627e96f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

posts/2025-11-11-making-race-condition-tests-deterministic-with-countdownlatch.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,21 @@ The production code remains clean. No test hooks, no debug flags, no conditional
155155

156156
Comment out the advisory lock:
157157

158+
```ruby
158159
# ApplicationRecord.with_advisory_lock('transfer_items', source_order_id) do
159160
items = projection.items_in_order(source_order_id)
160161
transfer(items.take(2), source_order_id, target_order_id)
161162
# end
162163

164+
```
163165
Run the test:
164166

167+
```
165168
Failure/Error: expect(items_in_target_1 & items_in_target_2).to be_empty
166169
expected: []
167170
got: ["item_A", "item_B"]
168171
(items appeared in both target orders - race condition detected!)
172+
```
169173

170174
Perfect. The test proves the lock is necessary.
171175

0 commit comments

Comments
 (0)