Skip to content

Commit 5eb4dc1

Browse files
committed
tests: Update
1 parent 252fd36 commit 5eb4dc1

File tree

3 files changed

+69
-38
lines changed

3 files changed

+69
-38
lines changed

__tests__/functions/environment-targets.test.js

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ test('checks the comment body and does not find an explicit environment target',
4646
stable_branch_used: false,
4747
params: null,
4848
parsed_params: null,
49-
sha: null
49+
sha: null,
50+
task: null
5051
}
5152
})
5253
expect(debugMock).toHaveBeenCalledWith(
@@ -72,7 +73,8 @@ test('checks the comment body and finds an explicit environment target for devel
7273
stable_branch_used: false,
7374
params: null,
7475
parsed_params: null,
75-
sha: null
76+
sha: null,
77+
task: null
7678
}
7779
})
7880
expect(debugMock).toHaveBeenCalledWith(
@@ -98,7 +100,8 @@ test('checks the comment body and finds an explicit environment target for devel
98100
stable_branch_used: false,
99101
params: 'something1 something2 something3',
100102
parsed_params: {_: ['something1', 'something2', 'something3']},
101-
sha: null
103+
sha: null,
104+
task: null
102105
}
103106
})
104107
expect(debugMock).toHaveBeenCalledWith(
@@ -131,7 +134,8 @@ test('checks the comment body and finds an explicit environment target and an ex
131134
stable_branch_used: false,
132135
params: 'something1 something2 something3',
133136
parsed_params: {_: ['something1', 'something2', 'something3']},
134-
sha: '82c238c277ca3df56fe9418a5913d9188eafe3bc'
137+
sha: '82c238c277ca3df56fe9418a5913d9188eafe3bc',
138+
task: null
135139
}
136140
})
137141
expect(debugMock).toHaveBeenCalledWith(
@@ -164,7 +168,8 @@ test('checks the comment body and finds an explicit environment target and an ex
164168
stable_branch_used: false,
165169
params: 'something1 something2 something3',
166170
parsed_params: {_: ['something1', 'something2', 'something3']},
167-
sha: '82c238c277ca3df56fe9418a5913d9188eafe3bc'
171+
sha: '82c238c277ca3df56fe9418a5913d9188eafe3bc',
172+
task: null
168173
}
169174
})
170175
expect(debugMock).toHaveBeenCalledWith(
@@ -206,7 +211,8 @@ test('checks the comment body and finds an explicit environment target and an ex
206211
name: 'my-app',
207212
q: 'my-queue'
208213
},
209-
sha: '82c238c277ca3df56fe9418a5913d9188eafe3bc'
214+
sha: '82c238c277ca3df56fe9418a5913d9188eafe3bc',
215+
task: null
210216
}
211217
})
212218
expect(debugMock).toHaveBeenCalledWith(
@@ -239,7 +245,8 @@ test('checks the comment body and finds an explicit environment target and an ex
239245
stable_branch_used: false,
240246
params: 'something1 something2 something3',
241247
parsed_params: {_: ['something1', 'something2', 'something3']},
242-
sha: 'f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b'
248+
sha: 'f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b',
249+
task: null
243250
}
244251
})
245252
expect(debugMock).toHaveBeenCalledWith(
@@ -272,7 +279,8 @@ test('checks the comment body and finds an explicit environment target and an ex
272279
stable_branch_used: false,
273280
params: null,
274281
parsed_params: null,
275-
sha: '82c238c277ca3df56fe9418a5913d9188eafe3bc'
282+
sha: '82c238c277ca3df56fe9418a5913d9188eafe3bc',
283+
task: null
276284
}
277285
})
278286

@@ -306,7 +314,8 @@ test('checks the comment body and finds an explicit environment target for devel
306314
stable_branch_used: true,
307315
params: 'something1 | something2 something3',
308316
parsed_params: {_: ['something1', '|', 'something2', 'something3']},
309-
sha: null
317+
sha: null,
318+
task: null
310319
}
311320
})
312321
expect(debugMock).toHaveBeenCalledWith(
@@ -339,7 +348,8 @@ test('checks the comment body and finds an explicit environment target for stagi
339348
stable_branch_used: false,
340349
params: null,
341350
parsed_params: null,
342-
sha: null
351+
sha: null,
352+
task: null
343353
}
344354
})
345355
expect(debugMock).toHaveBeenCalledWith(
@@ -365,7 +375,8 @@ test('checks the comment body and finds an explicit environment target for stagi
365375
stable_branch_used: true,
366376
params: null,
367377
parsed_params: null,
368-
sha: null
378+
sha: null,
379+
task: null
369380
}
370381
})
371382
expect(debugMock).toHaveBeenCalledWith(
@@ -396,7 +407,8 @@ test('checks the comment body and finds an explicit environment target for stagi
396407
stable_branch_used: false,
397408
params: null,
398409
parsed_params: null,
399-
sha: null
410+
sha: null,
411+
task: null
400412
}
401413
})
402414
expect(infoMock).toHaveBeenCalledWith(
@@ -440,7 +452,8 @@ test('checks the comment body and finds an explicit environment target for stagi
440452
stable_branch_used: true,
441453
params: 'something1 something2 something3',
442454
parsed_params: {_: ['something1', 'something2', 'something3']},
443-
sha: null
455+
sha: null,
456+
task: null
444457
}
445458
})
446459
expect(infoMock).toHaveBeenCalledWith(
@@ -489,7 +502,8 @@ test('checks the comment body and uses the default production environment target
489502
stable_branch_used: false,
490503
params: null,
491504
parsed_params: null,
492-
sha: null
505+
sha: null,
506+
task: null
493507
}
494508
})
495509
expect(infoMock).toHaveBeenCalledWith(
@@ -531,7 +545,8 @@ test('checks the comment body and finds an explicit environment target for a pro
531545
params: null,
532546
parsed_params: null,
533547
stable_branch_used: false,
534-
sha: null
548+
sha: null,
549+
task: null
535550
}
536551
})
537552
expect(debugMock).toHaveBeenCalledWith(
@@ -567,7 +582,8 @@ test('checks the comment body and finds an explicit environment target for a pro
567582
noop: false,
568583
params: null,
569584
parsed_params: null,
570-
sha: null
585+
sha: null,
586+
task: null
571587
}
572588
})
573589
expect(debugMock).toHaveBeenCalledWith(
@@ -606,7 +622,8 @@ test('checks the comment body and finds an explicit environment target for a pro
606622
noop: false,
607623
params: null,
608624
parsed_params: null,
609-
sha: null
625+
sha: null,
626+
task: null
610627
}
611628
})
612629
expect(debugMock).toHaveBeenCalledWith(
@@ -637,7 +654,8 @@ test('checks the comment body and finds an explicit environment target for stagi
637654
noop: true,
638655
params: null,
639656
parsed_params: null,
640-
sha: null
657+
sha: null,
658+
task: null
641659
}
642660
})
643661
expect(debugMock).toHaveBeenCalledWith(
@@ -663,7 +681,8 @@ test('checks the comment body and finds a noop deploy to the stable branch and d
663681
noop: true,
664682
params: null,
665683
parsed_params: null,
666-
sha: null
684+
sha: null,
685+
task: null
667686
}
668687
})
669688
expect(debugMock).toHaveBeenCalledWith(
@@ -689,7 +708,8 @@ test('checks the comment body and finds a noop deploy to the stable branch and d
689708
noop: true,
690709
params: 'foo=bar',
691710
parsed_params: {_: ['foo=bar']},
692-
sha: null
711+
sha: null,
712+
task: null
693713
}
694714
})
695715
expect(debugMock).toHaveBeenCalledWith(
@@ -715,7 +735,8 @@ test('checks the comment body and finds an explicit environment target for produ
715735
noop: false,
716736
params: null,
717737
parsed_params: null,
718-
sha: null
738+
sha: null,
739+
task: null
719740
}
720741
})
721742
expect(debugMock).toHaveBeenCalledWith(
@@ -741,7 +762,8 @@ test('checks the comment body on a noop deploy and does not find an explicit env
741762
noop: true,
742763
params: null,
743764
parsed_params: null,
744-
sha: null
765+
sha: null,
766+
task: null
745767
}
746768
})
747769
expect(debugMock).toHaveBeenCalledWith(
@@ -767,7 +789,8 @@ test('checks the comment body on a deployment and does not find any matching env
767789
parsed_params: null,
768790
stable_branch_used: null,
769791
target: false,
770-
sha: null
792+
sha: null,
793+
task: null
771794
}
772795
})
773796

@@ -799,7 +822,8 @@ test('checks the comment body on a stable branch deployment and finds a matching
799822
noop: false,
800823
params: null,
801824
parsed_params: null,
802-
sha: null
825+
sha: null,
826+
task: null
803827
}
804828
})
805829
expect(debugMock).toHaveBeenCalledWith(
@@ -825,7 +849,8 @@ test('checks the comment body on a stable branch deployment and finds a matching
825849
noop: false,
826850
params: null,
827851
parsed_params: null,
828-
sha: null
852+
sha: null,
853+
task: null
829854
}
830855
})
831856
expect(debugMock).toHaveBeenCalledWith(
@@ -851,7 +876,8 @@ test('checks the comment body on a stable branch deployment and uses the default
851876
noop: false,
852877
params: null,
853878
parsed_params: null,
854-
sha: null
879+
sha: null,
880+
task: null
855881
}
856882
})
857883
expect(debugMock).toHaveBeenCalledWith(
@@ -877,7 +903,8 @@ test('checks the comment body on a stable branch deployment and does not find a
877903
parsed_params: null,
878904
stable_branch_used: null,
879905
target: false,
880-
sha: null
906+
sha: null,
907+
task: null
881908
}
882909
})
883910

__tests__/functions/unlock-on-merge.test.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,18 @@ beforeEach(() => {
5555
})
5656

5757
test('successfully unlocks all environments on a pull request merge', async () => {
58+
process.env.INPUT_DEPLOYMENT_TASK = ''
5859
expect(
5960
await unlockOnMerge(octokit, context, environment_targets)
6061
).toStrictEqual(true)
6162
expect(infoMock).toHaveBeenCalledWith(
62-
`🔓 removed lock - environment: ${COLORS.highlight}staging${COLORS.reset}`
63+
`🔓 removed lock - branch: ${COLORS.highlight}staging-branch-deploy-lock${COLORS.reset}`
6364
)
6465
expect(infoMock).toHaveBeenCalledWith(
65-
`🔓 removed lock - environment: ${COLORS.highlight}development${COLORS.reset}`
66+
`🔓 removed lock - branch: ${COLORS.highlight}development-branch-deploy-lock${COLORS.reset}`
6667
)
6768
expect(infoMock).toHaveBeenCalledWith(
68-
`🔓 removed lock - environment: ${COLORS.highlight}production${COLORS.reset}`
69+
`🔓 removed lock - branch: ${COLORS.highlight}production-branch-deploy-lock${COLORS.reset}`
6970
)
7071
expect(setOutputMock).toHaveBeenCalledWith(
7172
'unlocked_environments',
@@ -74,6 +75,7 @@ test('successfully unlocks all environments on a pull request merge', async () =
7475
})
7576

7677
test('finds that no deployment lock is set so none are removed', async () => {
78+
process.env.INPUT_DEPLOYMENT_TASK = ''
7779
jest.spyOn(unlock, 'unlock').mockImplementation(() => {
7880
return 'no deployment lock currently set - silent'
7981
})
@@ -88,6 +90,7 @@ test('finds that no deployment lock is set so none are removed', async () => {
8890
})
8991

9092
test('only unlocks one environment because the other has no lock and the other is not associated with the pull request', async () => {
93+
process.env.INPUT_DEPLOYMENT_TASK = ''
9194
checkLockFile.checkLockFile.mockImplementationOnce(() => {
9295
return {
9396
link: 'https://github.com/corp/test/pull/111#issuecomment-123456789'
@@ -101,17 +104,18 @@ test('only unlocks one environment because the other has no lock and the other i
101104
await unlockOnMerge(octokit, context, environment_targets)
102105
).toStrictEqual(true)
103106
expect(infoMock).toHaveBeenCalledWith(
104-
`⏩ lock for PR ${COLORS.info}111${COLORS.reset} (env: ${COLORS.highlight}production${COLORS.reset}) is not associated with PR ${COLORS.info}123${COLORS.reset} - skipping...`
107+
`⏩ lock for PR ${COLORS.info}111${COLORS.reset} on branch ${COLORS.highlight}production-branch-deploy-lock${COLORS.reset} is not associated with PR ${COLORS.info}123${COLORS.reset} - skipping...`
105108
)
106109
expect(infoMock).toHaveBeenCalledWith(
107-
`⏩ no lock file found for environment ${COLORS.highlight}development${COLORS.reset} - skipping...`
110+
`⏩ no lock file found for branch ${COLORS.highlight}development-branch-deploy-lock${COLORS.reset} - skipping...`
108111
)
109112
expect(infoMock).toHaveBeenCalledWith(
110-
`🔓 removed lock - environment: ${COLORS.highlight}staging${COLORS.reset}`
113+
`🔓 removed lock - branch: ${COLORS.highlight}staging-branch-deploy-lock${COLORS.reset}`
111114
)
112115
})
113116

114117
test('only unlocks one environment because the other is not associated with the pull request and the other has no lock branch', async () => {
118+
process.env.INPUT_DEPLOYMENT_TASK = ''
115119
checkLockFile.checkLockFile.mockImplementationOnce(() => {
116120
return {
117121
link: 'https://github.com/corp/test/pull/111#issuecomment-123456789'
@@ -128,13 +132,13 @@ test('only unlocks one environment because the other is not associated with the
128132
await unlockOnMerge(octokit, context, environment_targets)
129133
).toStrictEqual(true)
130134
expect(infoMock).toHaveBeenCalledWith(
131-
`⏩ lock for PR ${COLORS.info}111${COLORS.reset} (env: ${COLORS.highlight}production${COLORS.reset}) is not associated with PR ${COLORS.info}123${COLORS.reset} - skipping...`
135+
`⏩ lock for PR ${COLORS.info}111${COLORS.reset} on branch ${COLORS.highlight}production-branch-deploy-lock${COLORS.reset} is not associated with PR ${COLORS.info}123${COLORS.reset} - skipping...`
132136
)
133137
expect(infoMock).toHaveBeenCalledWith(
134-
`⏩ no lock branch found for environment ${COLORS.highlight}development${COLORS.reset} - skipping...`
138+
`⏩ lock branch ${COLORS.highlight}development-branch-deploy-lock${COLORS.reset} no longer exists - skipping...`
135139
)
136140
expect(infoMock).toHaveBeenCalledWith(
137-
`🔓 removed lock - environment: ${COLORS.highlight}staging${COLORS.reset}`
141+
`🔓 removed lock - branch: ${COLORS.highlight}staging-branch-deploy-lock${COLORS.reset}`
138142
)
139143
})
140144

@@ -167,6 +171,6 @@ test('fails due to the context being a PR closed event but not a merge', async (
167171
'event name: pull_request, action: closed, merged: false'
168172
)
169173
expect(infoMock).toHaveBeenCalledWith(
170-
'pull request was closed but not merged so this workflow will not run - OK'
174+
"pull request was closed but not merged so this workflow will not run - OK (Use 'unlock-on-close' instead)"
171175
)
172176
})

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)