File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ const { createNamespace } = require('continuation-local-storage')
3030const {
3131 LambdaClient,
3232 CreateFunctionCommand,
33+ ListEventSourceMappingsCommand,
3334 GetFunctionCommand,
3435 UpdateFunctionCodeCommand,
3536 UpdateFunctionConfigurationCommand
@@ -766,16 +767,12 @@ they may not work as expected in the Lambda environment.
766767 return this . _zip ( program , codeDirectory )
767768 }
768769
769- _listEventSourceMappings ( lambda , params ) {
770- return new Promise ( ( resolve , reject ) => {
771- lambda . listEventSourceMappings ( params , ( err , data ) => {
772- if ( err ) return reject ( err )
773- if ( data && data . EventSourceMappings ) {
774- return resolve ( data . EventSourceMappings )
775- }
776- return resolve ( [ ] )
777- } )
778- } )
770+ async _listEventSourceMappings ( lambda , params ) {
771+ const data = await lambda . send ( new ListEventSourceMappingsCommand ( params ) )
772+ if ( data && data . EventSourceMappings ) {
773+ return data . EventSourceMappings
774+ }
775+ return [ ]
779776 }
780777
781778 _getStartingPosition ( eventSource ) {
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ const { mockClient } = require('aws-sdk-client-mock')
2020const {
2121 LambdaClient,
2222 CreateFunctionCommand,
23+ ListEventSourceMappingsCommand,
2324 GetFunctionCommand,
2425 UpdateFunctionCodeCommand,
2526 UpdateFunctionConfigurationCommand
@@ -175,6 +176,7 @@ describe('lib/main', function () {
175176 mockLambdaClient . on ( GetFunctionCommand ) . resolves ( lambdaMockSettings . getFunction )
176177 mockLambdaClient . on ( UpdateFunctionCodeCommand ) . resolves ( lambdaMockSettings . updateFunctionCode )
177178 mockLambdaClient . on ( UpdateFunctionConfigurationCommand ) . resolves ( lambdaMockSettings . updateFunctionConfiguration )
179+ mockLambdaClient . on ( ListEventSourceMappingsCommand ) . resolves ( lambdaMockSettings . listEventSourceMappings )
178180 } )
179181 after ( ( ) => {
180182 _awsRestore ( )
@@ -1358,7 +1360,7 @@ describe('lib/main', function () {
13581360 describe ( '_listEventSourceMappings' , ( ) => {
13591361 it ( 'simple test with mock' , ( ) => {
13601362 return lambda . _listEventSourceMappings (
1361- awsLambda ,
1363+ lambdaClient ,
13621364 { FunctionName : 'test-func' }
13631365 ) . then ( ( results ) => {
13641366 assert . deepEqual (
You can’t perform that action at this time.
0 commit comments