test: fix ndjson partial-tail truncation point
This commit is contained in:
1 parent
82c3763e5c
commit
33d8ac3046
1 file changed
+3
-2
@@ -16,8 +16,9 @@ def test_ndjson_roundtrip():
|
|||||||
|
|
||||||
def test_ndjson_partial_tail():
|
def test_ndjson_partial_tail():
|
||||||
a = {"id": 1}
|
a = {"id": 1}
|
||||||
b = {"id": 2}
|
b = {"id": 2, "payload": "x" * 50}
|
||||||
buf = encode_ndjson(a) + encode_ndjson(b)[:10] # b is incomplete
|
b_full = encode_ndjson(b)
|
||||||
|
buf = encode_ndjson(a) + b_full[:-1] # b truncated before its newline
|
||||||
msgs, consumed = decode_ndjson_lines(buf)
|
msgs, consumed = decode_ndjson_lines(buf)
|
||||||
assert msgs == [a]
|
assert msgs == [a]
|
||||||
assert consumed == len(encode_ndjson(a))
|
assert consumed == len(encode_ndjson(a))
|
||||||
|
|||||||
Reference in new issue
Block a user