test: fix ndjson partial-tail truncation point

This commit is contained in:
openbot committed 2026-10-06 11:07:14 +08:00
1 parent 82c3763e5c
commit 33d8ac3046
1 file changed
+3 -2
+3 -2
View File
@@ -16,8 +16,9 @@ def test_ndjson_roundtrip():
def test_ndjson_partial_tail():
a = {"id": 1}
b = {"id": 2}
buf = encode_ndjson(a) + encode_ndjson(b)[:10] # b is incomplete
b = {"id": 2, "payload": "x" * 50}
b_full = encode_ndjson(b)
buf = encode_ndjson(a) + b_full[:-1] # b truncated before its newline
msgs, consumed = decode_ndjson_lines(buf)
assert msgs == [a]
assert consumed == len(encode_ndjson(a))