@@ -85,7 +85,8 @@ const lambdaMockSettings = {
8585 } ,
8686 updateFunctionCode : {
8787 FunctionArn : 'Lambda.updateFunctionCode.mock.FunctionArn' ,
88- FunctionName : 'Lambda.updateFunctionCode.mock.FunctionName'
88+ FunctionName : 'Lambda.updateFunctionCode.mock.FunctionName' ,
89+ Version : '1'
8990 } ,
9091 updateFunctionConfiguration : {
9192 FunctionArn : 'Lambda.updateFunctionConfiguration.mock.FunctionArn' ,
@@ -107,7 +108,19 @@ const lambdaMockSettings = {
107108 Tags : { tag1 : 'key1' }
108109 } ,
109110 untagResource : { } ,
110- tagResource : { }
111+ tagResource : { } ,
112+ getAlias : {
113+ FunctionArn : 'Lambda.getAlias.mock.FunctionArn' ,
114+ Name : 'mockAlias'
115+ } ,
116+ createAlias : {
117+ FunctionArn : 'Lambda.createAlias.mock.FunctionArn' ,
118+ Name : 'mockAlias'
119+ } ,
120+ updateAlias : {
121+ FunctionArn : 'Lambda.updateAlias.mock.FunctionArn' ,
122+ Name : 'mockAlias'
123+ }
111124}
112125
113126const _mockSetting = ( ) => {
@@ -1575,7 +1588,27 @@ describe('lib/main', function () {
15751588 it ( 'simple test with mock' , ( ) => {
15761589 const params = lambda . _params ( program , null )
15771590 return lambda . _uploadExisting ( awsLambda , params ) . then ( ( results ) => {
1578- assert . deepEqual ( results , lambdaMockSettings . updateFunctionConfiguration )
1591+ assert . deepEqual ( results , lambdaMockSettings . updateFunctionCode )
1592+ } )
1593+ } )
1594+ } )
1595+
1596+ describe ( '_alias' , ( ) => {
1597+ it ( 'updates alias when it already exists' , ( ) => {
1598+ return lambda . _alias ( awsLambda , 'myFunc' , '1' , 'mockAlias' ) . then ( ( results ) => {
1599+ assert . deepEqual ( results , lambdaMockSettings . updateAlias )
1600+ } )
1601+ } )
1602+
1603+ it ( 'creates alias when it does not exist' , ( ) => {
1604+ const err = new Error ( 'ResourceNotFoundException' )
1605+ err . code = 'ResourceNotFoundException'
1606+ const mockLambda = {
1607+ getAlias : ( ) => ( { promise : ( ) => Promise . reject ( err ) } ) ,
1608+ createAlias : ( ) => ( { promise : ( ) => Promise . resolve ( lambdaMockSettings . createAlias ) } )
1609+ }
1610+ return lambda . _alias ( mockLambda , 'myFunc' , '1' , 'mockAlias' ) . then ( ( results ) => {
1611+ assert . deepEqual ( results , lambdaMockSettings . createAlias )
15791612 } )
15801613 } )
15811614 } )
@@ -1648,6 +1681,17 @@ describe('lib/main', function () {
16481681 )
16491682 } )
16501683 } )
1684+
1685+ it ( 'creates alias when publish and lambdaVersion are set' , ( ) => {
1686+ program . publish = true
1687+ program . lambdaVersion = 'v1'
1688+ const params = lambda . _params ( program , null )
1689+ params . Publish = true
1690+ return lambda . _deployToRegion ( program , params , 'us-east-1' ) . then ( ( result ) => {
1691+ assert . equal ( result . length , 4 )
1692+ assert . deepEqual ( result [ 3 ] , lambdaMockSettings . updateAlias )
1693+ } )
1694+ } )
16511695 } )
16521696
16531697 describe ( 'Lambda.prototype.deploy()' , ( ) => {
0 commit comments