Skip to content

Commit b2ec638

Browse files
d-v-bclaude
andcommitted
test(core): cover key-missing on uncoalescable input
Exercise the ``kind == "missing"`` branch in the uncoalescable single-fetch arm for Offset/Suffix/None inputs, which was not hit by existing tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 850b9cd commit b2ec638

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/test_coalesce.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,25 @@ async def fetch(byte_range: ByteRequest | None) -> Buffer | None:
287287
assert len(groups[0]) == 1
288288

289289

290+
@pytest.mark.parametrize(
291+
"byte_range",
292+
[
293+
OffsetByteRequest(5),
294+
SuffixByteRequest(5),
295+
None,
296+
],
297+
ids=["offset", "suffix", "none"],
298+
)
299+
async def test_key_missing_on_uncoalescable_input_yields_nothing(
300+
byte_range: ByteRequest | None,
301+
) -> None:
302+
# Uncoalescable inputs take a distinct code path from the merged-group
303+
# path; a missing key on that path must still short-circuit cleanly.
304+
fetch = FakeFetch(b"x" * 100, key_exists=False)
305+
groups = await _collect(coalesced_get(fetch, [byte_range], options=DEFAULT_COALESCE_OPTIONS))
306+
assert groups == []
307+
308+
290309
async def test_fetch_raises_propagates() -> None:
291310
fetch = FakeFetch(
292311
b"x" * 100,

0 commit comments

Comments
 (0)