diff --git a/index.js b/index.js index d51cc1e..4582d6f 100644 --- a/index.js +++ b/index.js @@ -40,7 +40,6 @@ exports.handler = async (event) => { key: key, "transcribe-provider": provider, pid: pid, - "api-key-id": apiKeyId, - "wat!":"?" + "api-key-id": apiKeyId } }; \ No newline at end of file diff --git a/test/test.js b/test/test.js index f875156..d96880c 100644 --- a/test/test.js +++ b/test/test.js @@ -15,63 +15,63 @@ describe('eventhandler', () => { s3ApiMock = require('./s3ApiMock'); s3ApiMock.reset(); }); - // - // it('collect head request without meta data', async () => { - // s3ApiMock.expectedHeadObjectParams({ - // Bucket: "s2t-base-s2tbucket-19xbw73dypb0s", - // Key: "gcp/not-transcoded/sugr1km8s6/f423fbfb-6381-11e8-a23f-c7cbebde15f2.ogg" - // }); - // - // s3ApiMock.givenResponseHeadObject({ - // AcceptRanges: "bytes", - // ContentLength: 3191, - // ContentType: "image/jpeg", - // ETag: "\"6805f2cfc46c0f04559748bb039d69ae\"", - // LastModified: '', - // Metadata: {}, - // }); - // - // let underTest = require('../index.js'); - // let snsMessage = await underTest.handler(event); - // - // expect(snsMessage).to.deep.equal({ - // bucket: "s2t-base-s2tbucket-19xbw73dypb0s", - // key: "gcp/not-transcoded/sugr1km8s6/f423fbfb-6381-11e8-a23f-c7cbebde15f2.ogg", - // "transcribe-provider": "gcp", - // pid: "f423fbfb-6381-11e8-a23f-c7cbebde15f2", - // "api-key-id": "sugr1km8s6" - // }); - // }); - // - // - // it('delegate collected meta data', async () => { - // - // s3ApiMock.expectedHeadObjectParams({ - // Bucket: "s2t-base-s2tbucket-19xbw73dypb0s", - // Key: "gcp/not-transcoded/sugr1km8s6/f423fbfb-6381-11e8-a23f-c7cbebde15f2.ogg" - // }); - // - // s3ApiMock.givenResponseHeadObject({ - // AcceptRanges: "bytes", - // ContentLength: 3191, - // ContentType: "image/jpeg", - // ETag: "\"6805f2cfc46c0f04559748bb039d69ae\"", - // LastModified: '', - // Metadata: { - // "api-key-id": "sugr1km8s6", - // "pid": "f423fbfb-6381-11e8-a23f-c7cbebde15f2", - // "transcribe-provider": "gcp" - // }, - // }); - // - // let underTest = require('../index.js'); - // let snsMessage = await underTest.handler(event); - // expect(snsMessage).to.deep.equal({ - // bucket: "s2t-base-s2tbucket-19xbw73dypb0s", - // key: "gcp/not-transcoded/sugr1km8s6/f423fbfb-6381-11e8-a23f-c7cbebde15f2.ogg", - // "transcribe-provider": "gcp", - // pid: "f423fbfb-6381-11e8-a23f-c7cbebde15f2", - // "api-key-id": "sugr1km8s6" - // }); - // }); + + it('collect head request without meta data', async () => { + s3ApiMock.expectedHeadObjectParams({ + Bucket: "s2t-base-s2tbucket-19xbw73dypb0s", + Key: "gcp/not-transcoded/sugr1km8s6/f423fbfb-6381-11e8-a23f-c7cbebde15f2.ogg" + }); + + s3ApiMock.givenResponseHeadObject({ + AcceptRanges: "bytes", + ContentLength: 3191, + ContentType: "image/jpeg", + ETag: "\"6805f2cfc46c0f04559748bb039d69ae\"", + LastModified: '', + Metadata: {}, + }); + + let underTest = require('../index.js'); + let snsMessage = await underTest.handler(event); + + expect(snsMessage).to.deep.equal({ + bucket: "s2t-base-s2tbucket-19xbw73dypb0s", + key: "gcp/not-transcoded/sugr1km8s6/f423fbfb-6381-11e8-a23f-c7cbebde15f2.ogg", + "transcribe-provider": "gcp", + pid: "f423fbfb-6381-11e8-a23f-c7cbebde15f2", + "api-key-id": "sugr1km8s6" + }); + }); + + + it('delegate collected meta data', async () => { + + s3ApiMock.expectedHeadObjectParams({ + Bucket: "s2t-base-s2tbucket-19xbw73dypb0s", + Key: "gcp/not-transcoded/sugr1km8s6/f423fbfb-6381-11e8-a23f-c7cbebde15f2.ogg" + }); + + s3ApiMock.givenResponseHeadObject({ + AcceptRanges: "bytes", + ContentLength: 3191, + ContentType: "image/jpeg", + ETag: "\"6805f2cfc46c0f04559748bb039d69ae\"", + LastModified: '', + Metadata: { + "api-key-id": "sugr1km8s6", + "pid": "f423fbfb-6381-11e8-a23f-c7cbebde15f2", + "transcribe-provider": "gcp" + }, + }); + + let underTest = require('../index.js'); + let snsMessage = await underTest.handler(event); + expect(snsMessage).to.deep.equal({ + bucket: "s2t-base-s2tbucket-19xbw73dypb0s", + key: "gcp/not-transcoded/sugr1km8s6/f423fbfb-6381-11e8-a23f-c7cbebde15f2.ogg", + "transcribe-provider": "gcp", + pid: "f423fbfb-6381-11e8-a23f-c7cbebde15f2", + "api-key-id": "sugr1km8s6" + }); + }); }); \ No newline at end of file