MCPcopy
hub / github.com/borgbackup/borg / test_partial_cache_chunk_buffer

Function test_partial_cache_chunk_buffer

src/borg/testsuite/archive_test.py:177–196  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

175
176
177def test_partial_cache_chunk_buffer():
178 big = "0123456789abcdefghijklmnopqrstuvwxyz" * 25000
179 data = [Item(path="full", target=big), Item(path="partial", target=big)]
180 cache = MockCache()
181 key = PlaintextKey(None)
182 chunks = CacheChunkBuffer(cache, key, None)
183 for d in data:
184 chunks.add(d)
185 chunks.flush(flush=False)
186 # the code is expected to leave the last partial chunk in the buffer
187 assert len(chunks.chunks) == 3
188 assert chunks.buffer.tell() > 0
189 # now really flush
190 chunks.flush(flush=True)
191 assert len(chunks.chunks) == 4
192 assert chunks.buffer.tell() == 0
193 unpacker = msgpack.Unpacker()
194 for id in chunks.chunks:
195 unpacker.feed(cache.objects[id])
196 assert data == [Item(internal_dict=d) for d in unpacker]
197
198
199def make_chunks(items):

Callers

nothing calls this directly

Calls 7

MockCacheClass · 0.85
PlaintextKeyClass · 0.85
CacheChunkBufferClass · 0.85
feedMethod · 0.80
addMethod · 0.45
flushMethod · 0.45
tellMethod · 0.45

Tested by

no test coverage detected