@@ -7,6 +7,7 @@ import * as postDeployMessage from '../../src/functions/post-deploy-message'
77import * as core from '@actions/core'
88
99const infoMock = jest . spyOn ( core , 'info' )
10+ const warningMock = jest . spyOn ( core , 'warning' )
1011
1112var octokit
1213var context
@@ -15,6 +16,7 @@ beforeEach(() => {
1516 jest . clearAllMocks ( )
1617 jest . spyOn ( core , 'info' ) . mockImplementation ( ( ) => { } )
1718 jest . spyOn ( core , 'debug' ) . mockImplementation ( ( ) => { } )
19+ jest . spyOn ( core , 'warning' ) . mockImplementation ( ( ) => { } )
1820 jest . spyOn ( actionStatus , 'actionStatus' ) . mockImplementation ( ( ) => {
1921 return undefined
2022 } )
@@ -310,6 +312,51 @@ test('successfully completes a noop branch deployment and removes a non-sticky l
310312 )
311313} )
312314
315+ test ( 'successfully completes a noop branch deployment but does not get any lock data' , async ( ) => {
316+ const lockSpy = jest . spyOn ( lock , 'lock' ) . mockImplementation ( ( ) => {
317+ return { lockData : null }
318+ } )
319+ const actionStatusSpy = jest . spyOn ( actionStatus , 'actionStatus' )
320+ expect (
321+ await postDeploy (
322+ context ,
323+ octokit ,
324+ 123 ,
325+ 12345 ,
326+ 'success' ,
327+ 'test-ref' ,
328+ true ,
329+ 456 ,
330+ 'production'
331+ )
332+ ) . toBe ( 'success - noop' )
333+
334+ expect ( lockSpy ) . toHaveBeenCalled ( )
335+ expect ( actionStatusSpy ) . toHaveBeenCalled ( )
336+ expect ( actionStatusSpy ) . toHaveBeenCalledWith (
337+ {
338+ actor : 'monalisa' ,
339+ eventName : 'issue_comment' ,
340+ payload : { comment : { id : '1' } } ,
341+ repo : { owner : 'corp' , repo : 'test' } ,
342+ workflow : 'test-workflow'
343+ } ,
344+ {
345+ rest : {
346+ repos : {
347+ createDeploymentStatus : octokit . rest . repos . createDeploymentStatus
348+ }
349+ }
350+ } ,
351+ 12345 ,
352+ 'Updated 1 server' ,
353+ true
354+ )
355+ expect ( warningMock ) . toHaveBeenCalledWith (
356+ 'a request to obtain the lock data returned null or undefined - the lock may have been removed by another process while this Action was running'
357+ )
358+ } )
359+
313360test ( 'successfully completes a production branch deployment with no custom message' , async ( ) => {
314361 const actionStatusSpy = jest . spyOn ( actionStatus , 'actionStatus' )
315362 expect (
0 commit comments