Skip to content

Commit

Permalink
update s3 storage get() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sotojn committed Apr 23, 2024
1 parent f22595c commit 02a17d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/teraslice/test/storage/assets_storage-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ describe('AssetsStorage using S3 backend', () => {
});

it('can get an asset from S3', async () => {
/// create a buffer copy of example_asset_1.zip to test if it equals what s3 sends back
const filePath = 'e2e/test/fixtures/assets/example_asset_1.zip';
const buffer = fs.readFileSync(filePath);
const assetRecord = await storage.get('2909ec5fd38466cf6276cc14ede25096f1f34ee9');
expect(assetRecord.blob).toStartWith('UEsDBAoAAAAAANxV');
expect(buffer.equals(assetRecord.blob as Buffer)).toBe(true);
expect(assetRecord.name).toBe('ex1');
});

Expand Down
5 changes: 3 additions & 2 deletions packages/teraslice/test/storage/s3_store-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,12 @@ describe('S3 backend test', () => {

it('should be able to download asset', async () => {
const filePath = 'e2e/test/fixtures/assets/example_asset_2.zip';
await s3Backend.save('ex2', fse.readFileSync(filePath), 30000);
const fileBuffer = fse.readFileSync(filePath);
await s3Backend.save('ex2', fileBuffer, 30000);

const result = await s3Backend.get('ex2');

expect(result).toStartWith('UEsDBAo');
expect(result.equals(fileBuffer)).toBe(true);
await s3Backend.remove('ex2');
});
});
Expand Down

0 comments on commit 02a17d7

Please sign in to comment.