From 8ae73a2b5c84615183a0738501966c89b9fa56c3 Mon Sep 17 00:00:00 2001 From: jubnl Date: Wed, 19 Aug 2026 20:20:58 +0200 Subject: [PATCH] test(server): pin ranged-read stat and zero-byte roundtrip in the storage driver contract --- .../nest/storage/storage-driver.contract.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server/tests/unit/nest/storage/storage-driver.contract.ts b/server/tests/unit/nest/storage/storage-driver.contract.ts index 338e43543..c50e0fb8a 100644 --- a/server/tests/unit/nest/storage/storage-driver.contract.ts +++ b/server/tests/unit/nest/storage/storage-driver.contract.ts @@ -81,6 +81,23 @@ export function describeStorageDriver(name: string, makeHarness: () => Promise { + // Pins LocalDriver parity for remote drivers: size is the TOTAL object + // size (S3: from the 206 Content-Range total), never the range length. + await h.driver.put('a/rstat.bin', Readable.from('0123456789')); + const { stream, stat } = await h.driver.getStream('a/rstat.bin', { start: 2, end: 5 }); + for await (const _ of stream) void _; // drain so the harness can clean up + expect(stat).toMatchObject({ key: 'a/rstat.bin', size: 10 }); + }); + + it('roundtrips a zero-byte stream source', async () => { + await h.driver.put('a/empty.bin', Readable.from([])); + expect((await readAll('a/empty.bin')).length).toBe(0); + expect((await h.driver.stat('a/empty.bin'))!.size).toBe(0); + await h.driver.delete('a/empty.bin'); + expect(await h.driver.stat('a/empty.bin')).toBeNull(); + }); + it('rejects getStream on a missing key with StorageNotFoundError', async () => { await expect(h.driver.getStream('a/nope.bin')).rejects.toBeInstanceOf(StorageNotFoundError); });