All files / blong-int-adapter/s3/test/test testS3ObjectPut.ts

100% Statements 26/26
100% Branches 4/4
100% Functions 3/3
100% Lines 26/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 271x 1x 1x 1x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x  
import {handler, type IMeta} from '@feasibleone/blong';
import type Assert from 'node:assert';
 
export default handler(({lib: {group}, handler: {storageObjectAdd, storageObjectGet}}) => ({
    testS3ObjectPut: ({name = 's3 object put/get round-trip'}: {name?: string}) =>
        group(name)([
            async function putObject(assert: typeof Assert, {$meta}: {$meta: IMeta}) {
                const testContent = 'blong-s3-test-' + Date.now();
                const result = await storageObjectAdd(
                    {key: 'test/blong-test.txt', body: testContent, contentType: 'text/plain'},
                    $meta,
                );
                assert.ok(result, 'Put should return a result');
                return {key: 'test/blong-test.txt', content: testContent};
            },
            async function getObject(
                assert: typeof Assert,
                {$meta, putObject}: {$meta: IMeta; putObject: Promise<{key: string}>},
            ) {
                const {key} = await putObject;
                const result = await storageObjectGet({key}, $meta);
                assert.ok(result, 'Get should return a result');
                return result;
            },
        ]),
}));