fix: preserve pending occurrence pagination bounds
This commit is contained in:
@@ -787,6 +787,65 @@ async def test_occurrences_pending_synthesis_first_page_only(tmp_path: Path) ->
|
||||
assert all(row["kind"] != "pending" for row in plain["occurrences"])
|
||||
|
||||
|
||||
async def test_occurrences_pending_limit_one_traverses_every_row(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""A synthesized pending row must not make the first stored row unreachable."""
|
||||
api, sched_store, _, _, _ = _harness(tmp_path / "pending_limit_one")
|
||||
await api.create_schedule(
|
||||
schedule_id="s", deployment_id="dep.personal", trigger=_cron()
|
||||
)
|
||||
base = ts(2026, 9, 8, 12, 0)
|
||||
recorder = FileScheduleHistoryRecorder(sched_store)
|
||||
for index in range(3):
|
||||
instant = base + timedelta(minutes=index)
|
||||
recorder.record(
|
||||
HistoryEntry(
|
||||
schedule_id="s",
|
||||
kind="admitted",
|
||||
resolved_at=instant,
|
||||
run_id=f"run-{index}",
|
||||
revision=1,
|
||||
reason="rev=1",
|
||||
created_at=instant,
|
||||
)
|
||||
)
|
||||
sched_store.save_candidate(
|
||||
PendingCandidate(
|
||||
schedule_id="s",
|
||||
intended_at=base + timedelta(hours=1),
|
||||
revision=1,
|
||||
),
|
||||
schedule_id="s",
|
||||
)
|
||||
|
||||
rows: list[dict[str, Any]] = []
|
||||
cursor: str | None = None
|
||||
for _ in range(5):
|
||||
page = await api.list_schedule_occurrences(
|
||||
schedule_id="s", cursor=cursor, limit=1
|
||||
)
|
||||
assert len(page["occurrences"]) <= 1
|
||||
rows.extend(page["occurrences"])
|
||||
cursor = page["next_cursor"]
|
||||
if cursor is None:
|
||||
break
|
||||
else:
|
||||
pytest.fail("occurrence pagination did not terminate")
|
||||
|
||||
assert [row["kind"] for row in rows] == [
|
||||
"pending",
|
||||
"admitted",
|
||||
"admitted",
|
||||
"admitted",
|
||||
]
|
||||
assert [row["run_id"] for row in rows[1:]] == [
|
||||
"run-0",
|
||||
"run-1",
|
||||
"run-2",
|
||||
]
|
||||
|
||||
|
||||
async def test_occurrences_pagination_visits_tied_entries_once(tmp_path: Path) -> None:
|
||||
"""One occurrence's admission + stops each appear exactly once (B4).
|
||||
|
||||
|
||||
@@ -242,8 +242,8 @@ async def test_rpc_schedule_occurrences_pagination_and_pending(tmp_path) -> None
|
||||
assert first["total"] == 4
|
||||
assert first["cursor"] is None
|
||||
assert first["limit"] == 2
|
||||
# The pending synthesis prepends one row to the stored page.
|
||||
assert len(first["occurrences"]) == 3
|
||||
# The pending synthesis consumes one slot from the stored page.
|
||||
assert len(first["occurrences"]) == 2
|
||||
pending = first["occurrences"][0]
|
||||
assert pending["kind"] == "pending"
|
||||
assert pending["schedule_id"] == "s"
|
||||
|
||||
Reference in New Issue
Block a user