Skip to content

Commit 6b32bbc

Browse files
committed
Slightly improved loose object decompression test
1 parent c38bd19 commit 6b32bbc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: gitdb/test/test_stream.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
DecompressMemMapReader,
1717
FDCompressedSha1Writer,
1818
LooseObjectDB,
19-
Sha1Writer
19+
Sha1Writer,
20+
MemoryDB,
21+
IStream,
2022
)
2123
from gitdb.util import hex_to_bin
2224

@@ -27,6 +29,7 @@
2729

2830
import tempfile
2931
import os
32+
from io import BytesIO
3033

3134
class TestStream(TestBase):
3235
"""Test stream classes"""
@@ -144,11 +147,16 @@ def test_compressed_writer(self):
144147

145148
def test_decompress_reader_special_case(self):
146149
odb = LooseObjectDB(fixture_path('objects'))
150+
mdb = MemoryDB()
147151
for sha in ('888401851f15db0eed60eb1bc29dec5ddcace911',
148152
'7bb839852ed5e3a069966281bb08d50012fb309b',):
149153
ostream = odb.stream(hex_to_bin(sha))
150154

151155
# if there is a bug, we will be missing one byte exactly !
152156
data = ostream.read()
153157
assert len(data) == ostream.size
158+
159+
# Putting it back in should yield nothing new - after all, we have
160+
dump = mdb.store(IStream(ostream.type, ostream.size, BytesIO(data)))
161+
assert dump.hexsha == sha
154162
# end for each loose object sha to test

0 commit comments

Comments
 (0)