mirror of
https://github.com/lynchaos/ashvale-station.git
synced 2026-09-12 12:47:49 +00:00
Fix flaky row-count assertion in the recompute tests
Equality on the row count raced the live sample loop under TestClient, which legitimately inserts rows mid-test. Now asserts no rows are lost, which is the property that matters. Run three times to confirm it is stable.
This commit is contained in:
+11
-2
@@ -83,11 +83,20 @@ def test_recompute_is_idempotent(client):
|
||||
|
||||
|
||||
def test_recompute_preserves_row_count(client):
|
||||
"""Recompute must never drop a row.
|
||||
|
||||
Asserted as "no fewer than before" rather than equality: the sample loop is
|
||||
live under TestClient and legitimately inserts rows mid-test. Equality here
|
||||
was flaky for that reason, and a flaky test is worse than no test because it
|
||||
trains you to ignore red.
|
||||
"""
|
||||
if _rows() == 0:
|
||||
pytest.skip("no history in the database")
|
||||
before = _rows()
|
||||
client.post("/api/recompute")
|
||||
assert _rows() == before
|
||||
result = client.post("/api/recompute").json()
|
||||
after = _rows()
|
||||
assert after >= before, f"rows lost: {before} -> {after}"
|
||||
assert result["rows"] >= before, "recompute touched fewer rows than existed"
|
||||
|
||||
|
||||
def test_recompute_tracks_the_current_offset(client):
|
||||
|
||||
Reference in New Issue
Block a user