@@ -7,6 +7,7 @@ import * as postDeployMessage from '../../src/functions/post-deploy-message'
7
7
import * as core from '@actions/core'
8
8
9
9
const infoMock = jest . spyOn ( core , 'info' )
10
+ const warningMock = jest . spyOn ( core , 'warning' )
10
11
11
12
var octokit
12
13
var context
@@ -15,6 +16,7 @@ beforeEach(() => {
15
16
jest . clearAllMocks ( )
16
17
jest . spyOn ( core , 'info' ) . mockImplementation ( ( ) => { } )
17
18
jest . spyOn ( core , 'debug' ) . mockImplementation ( ( ) => { } )
19
+ jest . spyOn ( core , 'warning' ) . mockImplementation ( ( ) => { } )
18
20
jest . spyOn ( actionStatus , 'actionStatus' ) . mockImplementation ( ( ) => {
19
21
return undefined
20
22
} )
@@ -310,6 +312,51 @@ test('successfully completes a noop branch deployment and removes a non-sticky l
310
312
)
311
313
} )
312
314
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
+
313
360
test ( 'successfully completes a production branch deployment with no custom message' , async ( ) => {
314
361
const actionStatusSpy = jest . spyOn ( actionStatus , 'actionStatus' )
315
362
expect (
0 commit comments