aws-lambda-runner 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02a25fc49fd3eafef4217ed89fee0f03523d2ae1
4
- data.tar.gz: a23326cae68fadc367e0be12a01944f641e44427
3
+ metadata.gz: 78b58c68e4c4909928cec2e6263ea977e541a4b4
4
+ data.tar.gz: de347cece2b17bca7a3f51e1ad91b227e45a0826
5
5
  SHA512:
6
- metadata.gz: d55ba5125d2f3455ef347c414459c8453dcc2962012112446b0b095d35ddccc8dbd157515f345137497389d41d79de4381f7580c68e6b88474a9d515865a4a7b
7
- data.tar.gz: cf48f073bd69ff9e14d054c2fa90ae15ce573f714f5f347b592c5d7b16349adf454766d74b0183d0c655ffa0ca9ca9e28e82653d35aa9aea8adbfe69328f2347
6
+ metadata.gz: 85b9c53ed6d877fc7207fbb36532cf67786b9b4297578a0b0d0736727e248fbd3ad93dfef2645e29dc23579b31a2dcc412be48b021c8d96dbed7bbeceaa45941
7
+ data.tar.gz: 193d8f2fe283012a52ab53022fdbc7011b610e5e91167832753e973b8be98a6b0d9ef5bc7fc900c3ca34befb0c387b8964cfc91c6cb2b71c5231ec41de8c8cee
@@ -75,7 +75,7 @@ module LambdaRunner
75
75
  # aws events
76
76
  class Events
77
77
  def self.s3_event(bucket, key, local_path)
78
- event = load_json('sample_req.json')
78
+ event = load_json('sample_s3_event.json')
79
79
  event['Records'].each do |record|
80
80
  record['file'] = { 'path' => local_path }
81
81
  record['s3']['bucket'].update('name' => bucket,
@@ -87,12 +87,12 @@ module LambdaRunner
87
87
  end
88
88
 
89
89
  def self.sns_event(topicArn, messageId, timestamp, messageBody)
90
- event = load_json('sample_sns_req.json')
90
+ event = load_json('sample_sns_event.json')
91
91
  event['Records'].each do |record|
92
- record['Sns']['topicArn'] = topicArn
93
- record['Sns']['messageId'] = messageId
94
- record['Sns']['timestamp'] = timestamp
95
- record['Sns']['messageBody'] = messageBody
92
+ record['Sns']['TopicArn'] = topicArn
93
+ record['Sns']['MessageId'] = messageId
94
+ record['Sns']['Timestamp'] = timestamp
95
+ record['Sns']['Message'] = messageBody
96
96
  end
97
97
  event.to_json
98
98
  end
@@ -0,0 +1,24 @@
1
+ require 'rspec'
2
+ require_relative '../lib/lambda_runner'
3
+
4
+ describe LambdaRunner::Events do
5
+
6
+ it "should generate an S3 event" do
7
+ json = LambdaRunner::Events.s3_event("some-bucket", "some/key", "local/path")
8
+ data = JSON.parse json
9
+ expect(data["Records"][0]["file"]["path"]).to eq("local/path")
10
+ expect(data["Records"][0]["s3"]["bucket"]["name"]).to eq("some-bucket")
11
+ expect(data["Records"][0]["s3"]["bucket"]["arn"]).to eq("arn:aws:s3:::some-bucket")
12
+ expect(data["Records"][0]["s3"]["object"]["key"]).to eq("some/key")
13
+ end
14
+
15
+ it "should generate an SNS event" do
16
+ json = LambdaRunner::Events.sns_event("some-arn", "some-id", "some-timestamp", "some-body")
17
+ data = JSON.parse json
18
+ expect(data["Records"][0]["Sns"]["TopicArn"]).to eq("some-arn")
19
+ expect(data["Records"][0]["Sns"]["MessageId"]).to eq("some-id")
20
+ expect(data["Records"][0]["Sns"]["Timestamp"]).to eq("some-timestamp")
21
+ expect(data["Records"][0]["Sns"]["Message"]).to eq("some-body")
22
+ end
23
+
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-lambda-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - andrew wheat
@@ -106,8 +106,9 @@ files:
106
106
  - js/request.js
107
107
  - js/startup.js
108
108
  - lib/lambda_runner.rb
109
- - lib/sample_req.json
110
- - lib/sample_sns_req.json
109
+ - lib/sample_s3_event.json
110
+ - lib/sample_sns_event.json
111
+ - spec/lambda-runner_spec.rb
111
112
  homepage: https://github.com/bbc/aws-lambda-runner
112
113
  licenses:
113
114
  - Apache 2