aws-lambda-helper
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -82,3 +82,8 @@ 'use strict'; | ||
return AwsHelper._Lambda.invoke(p, cb); | ||
return AwsHelper._Lambda.invoke(p, function (err, data) { | ||
if (err) return cb(err); | ||
var payload = JSON.parse(data.Payload); | ||
if (payload.errorMessage) return cb(payload); | ||
return cb(null, payload); | ||
}); | ||
}; | ||
@@ -85,0 +90,0 @@ |
{ | ||
"name": "aws-lambda-helper", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Collection of helper methods for lambda", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -45,3 +45,3 @@ 'use strict'; | ||
assert.deepEqual(p, params); | ||
cb(null, 'totes worked'); | ||
cb(null, {Payload: '{"totes": "worked"}'}); | ||
}); | ||
@@ -58,3 +58,3 @@ | ||
assert(err === null); | ||
assert(data === 'totes worked'); | ||
assert.deepEqual(data, { 'totes': 'worked' }); | ||
done(); | ||
@@ -82,3 +82,3 @@ }); | ||
assert.deepEqual(p, params); | ||
cb(null, 'totes worked'); | ||
cb(null, {Payload: '{"totes": "worked"}'}); | ||
}); | ||
@@ -95,3 +95,3 @@ | ||
assert(err === null); | ||
assert(data === 'totes worked'); | ||
assert.deepEqual(data, { 'totes': 'worked' }); | ||
done(); | ||
@@ -101,2 +101,13 @@ }); | ||
it('should return error to the callback when the result contains an errorMessage', function (done) { | ||
simple.mock(AwsHelper._Lambda, 'invoke').callbackWith(null, {Payload: '{"errorMessage": "some error"}'}); | ||
var p = { | ||
FunctionName: 'a name' | ||
}; | ||
AwsHelper.Lambda.invoke(p, function (err, data) { | ||
assert.deepEqual(err, {'errorMessage': 'some error'}); | ||
done(); | ||
}); | ||
}); | ||
it('should create a Lambda object when not initiated', function (done) { | ||
@@ -103,0 +114,0 @@ var context = { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
116623
896