forked from oss-serverless/serverless
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.test.js
More file actions
73 lines (66 loc) · 2.14 KB
/
function.test.js
File metadata and controls
73 lines (66 loc) · 2.14 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'use strict';
const { expect } = require('chai');
const awsRequest = require('../../lib/aws-request');
const LambdaService = require('aws-sdk').Lambda;
const fixtures = require('../../fixtures/programmatic');
const { confirmCloudWatchLogs } = require('../../utils/misc');
const { deployService, removeService } = require('../../utils/integration');
describe('test/integration/aws/function.test.js', function () {
this.timeout(1000 * 60 * 20); // Involves time-taking deploys
let stackName;
let serviceDir;
const stage = 'dev';
before(async () => {
const serviceData = await fixtures.setup('function', {
configExt: {
functions: {
arch: {
handler: 'basic.handler',
architecture: 'arm64',
},
target: {
handler: 'target.handler',
},
trigger: {
handler: 'trigger.handler',
destinations: { onSuccess: 'target' },
},
},
},
});
({ servicePath: serviceDir } = serviceData);
const serviceName = serviceData.serviceConfig.service;
stackName = `${serviceName}-${stage}`;
await deployService(serviceDir);
});
after(async () => {
if (!serviceDir) return;
await removeService(serviceDir);
});
it('should invoke destination target on async invocation', async () => {
const events = await confirmCloudWatchLogs(
`/aws/lambda/${stackName}-target`,
async () => {
await awsRequest(LambdaService, 'invoke', {
FunctionName: `${stackName}-trigger`,
InvocationType: 'Event',
});
},
{ checkIsComplete: (soFarEvents) => soFarEvents.length }
);
expect(events.length > 0).to.equal(true);
});
it('should run lambda in `arm64` architecture', async () => {
const events = await confirmCloudWatchLogs(
`/aws/lambda/${stackName}-arch`,
async () => {
await awsRequest(LambdaService, 'invoke', {
FunctionName: `${stackName}-arch`,
InvocationType: 'Event',
});
},
{ checkIsComplete: (soFarEvents) => soFarEvents.length }
);
expect(events.length > 0).to.equal(true);
});
});