node-lambda 1.3.0 → 2.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/workflow.yml +2 -2
- package/README.md +1 -1
- package/bin/node-lambda +1 -1
- package/lib/.env.example +1 -0
- package/lib/aws.js +41 -38
- package/lib/cloudwatch_logs.js +22 -32
- package/lib/main.js +142 -168
- package/lib/s3_deploy.js +18 -24
- package/lib/s3_events.js +16 -27
- package/lib/schedule_events.js +21 -35
- package/package.json +12 -9
- package/tea.yaml +6 -0
- package/test/cloudwatch_logs.js +17 -13
- package/test/main.js +92 -60
- package/test/node-lambda.js +17 -6
- package/test/s3_deploy.js +15 -15
- package/test/s3_events.js +15 -17
- package/test/schedule_events.js +15 -17
package/test/s3_events.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
let assert
|
|
4
|
+
import('chai').then(chai => {
|
|
5
|
+
assert = chai.assert
|
|
6
|
+
})
|
|
7
|
+
const { S3Client, PutBucketNotificationConfigurationCommand } = require('@aws-sdk/client-s3')
|
|
8
|
+
const { LambdaClient, AddPermissionCommand } = require('@aws-sdk/client-lambda')
|
|
9
|
+
const { mockClient } = require('aws-sdk-client-mock')
|
|
10
|
+
const mockS3Client = mockClient(S3Client)
|
|
11
|
+
const mockLambdaClient = mockClient(LambdaClient)
|
|
7
12
|
const S3Events = require('../lib/s3_events')
|
|
8
13
|
|
|
9
14
|
const params = {
|
|
@@ -30,22 +35,15 @@ const mockResponse = {
|
|
|
30
35
|
|
|
31
36
|
let s3Events = null
|
|
32
37
|
|
|
33
|
-
/* global before,
|
|
38
|
+
/* global before, describe, it */
|
|
34
39
|
describe('lib/s3_events', () => {
|
|
35
40
|
before(() => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
callback(null, mockResponse.putBucketNotificationConfiguration)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
s3Events = new S3Events(require('aws-sdk'))
|
|
44
|
-
})
|
|
41
|
+
mockS3Client.reset()
|
|
42
|
+
mockS3Client.on(PutBucketNotificationConfigurationCommand).resolves(mockResponse.putBucketNotificationConfiguration)
|
|
43
|
+
mockLambdaClient.reset()
|
|
44
|
+
mockLambdaClient.on(AddPermissionCommand).resolves(mockResponse.addPermission)
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
aws.restore('Lambda')
|
|
48
|
-
aws.restore('S3')
|
|
46
|
+
s3Events = new S3Events({ region: 'us-west-1' })
|
|
49
47
|
})
|
|
50
48
|
|
|
51
49
|
describe('_functionName', () => {
|
package/test/schedule_events.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
let assert
|
|
4
|
+
import('chai').then(chai => {
|
|
5
|
+
assert = chai.assert
|
|
6
|
+
})
|
|
4
7
|
const path = require('path')
|
|
5
|
-
const
|
|
6
|
-
|
|
8
|
+
const { CloudWatchEventsClient, PutRuleCommand, PutTargetsCommand } = require('@aws-sdk/client-cloudwatch-events')
|
|
9
|
+
const { LambdaClient, AddPermissionCommand } = require('@aws-sdk/client-lambda')
|
|
10
|
+
const { mockClient } = require('aws-sdk-client-mock')
|
|
11
|
+
const mockCloudWatchEventsClient = mockClient(CloudWatchEventsClient)
|
|
12
|
+
const mockLambdaClient = mockClient(LambdaClient)
|
|
7
13
|
const ScheduleEvents = require(path.join('..', 'lib', 'schedule_events'))
|
|
8
14
|
|
|
9
15
|
const params = {
|
|
@@ -41,22 +47,14 @@ let schedule = null
|
|
|
41
47
|
/* global before, after, describe, it */
|
|
42
48
|
describe('lib/schedule_events', () => {
|
|
43
49
|
before(() => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
aws.mock('CloudWatchEvents', 'putTargets', (params, callback) => {
|
|
48
|
-
callback(null, mockResponse.putTargets)
|
|
49
|
-
})
|
|
50
|
-
aws.mock('Lambda', 'addPermission', (params, callback) => {
|
|
51
|
-
callback(null, mockResponse.addPermission)
|
|
52
|
-
})
|
|
50
|
+
mockCloudWatchEventsClient.reset()
|
|
51
|
+
mockCloudWatchEventsClient.on(PutRuleCommand).resolves(mockResponse.putRule)
|
|
52
|
+
mockCloudWatchEventsClient.on(PutTargetsCommand).resolves(mockResponse.putTargets)
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
mockLambdaClient.reset()
|
|
55
|
+
mockLambdaClient.on(AddPermissionCommand).resolves(mockResponse.addPermission)
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
aws.restore('CloudWatchEvents')
|
|
59
|
-
aws.restore('Lambda')
|
|
57
|
+
schedule = new ScheduleEvents({ region: 'us-west-1' })
|
|
60
58
|
})
|
|
61
59
|
|
|
62
60
|
describe('_ruleDescription (default)', () => {
|