Skip to content

Commit

Permalink
TransferManager#downloadFileInChunks test case for failed CRC32C vali…
Browse files Browse the repository at this point in the history
…dation
  • Loading branch information
rhodgkins committed Nov 29, 2023
1 parent 2310d72 commit 5045acf
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/transfer-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,22 @@ describe('Transfer Manager', () => {
assert.strictEqual(callCount, 1);
});

it('should throw an error if crc32c validation fails', async () => {
file.download = () => {
return Promise.resolve([Buffer.alloc(0)]) as Promise<DownloadResponse>;
};
CRC32C.fromFile = () => {
return Promise.resolve(new CRC32C(1)); // Set non-expected initial value
};

await assert.rejects(
transferManager.downloadFileInChunks(file, {validation: 'crc32c'}),
{
code: 'CONTENT_DOWNLOAD_MISMATCH',
}
);
});

it('should set the appropriate `GCCL_GCS_CMD_KEY`', async () => {
sandbox.stub(file, 'download').callsFake(async options => {
assert.strictEqual(
Expand Down

0 comments on commit 5045acf

Please sign in to comment.