Skip to content

Commit a95f851

Browse files
committed
control flow improvements for unlock-on-merge
1 parent a4e9c30 commit a95f851

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,20 @@ test('successfully unlocks all environments on a pull request merge', async () =
6868
)
6969
})
7070

71+
test('finds that no deployment lock is set so none are removed', async () => {
72+
jest.spyOn(unlock, 'unlock').mockImplementation(() => {
73+
return 'no deployment lock currently set - silent'
74+
})
75+
76+
expect(
77+
await unlockOnMerge(octokit, context, environment_targets)
78+
).toStrictEqual(true)
79+
expect(debugMock).toHaveBeenCalledWith(
80+
'unlock result for unlock-on-merge: no deployment lock currently set - silent'
81+
)
82+
expect(setOutputMock).toHaveBeenCalledWith('unlocked_environments', '')
83+
})
84+
7185
test('only unlocks one environment because the other has no lock and the other is not associated with the pull request', async () => {
7286
checkLockFile.checkLockFile.mockImplementationOnce(() => {
7387
return {

dist/index.js

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/functions/unlock-on-merge.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export async function unlockOnMerge(octokit, context, environment_targets) {
5353
// if the result is 'removed lock - silent', then the lock was successfully removed - append to the array for later use
5454
if (result === 'removed lock - silent') {
5555
releasedEnvironments.push(environment)
56+
} else {
57+
core.debug(`unlock result for unlock-on-merge: ${result}`)
5658
}
5759

5860
// log the result and format the output as it will always be a string ending with '- silent'
@@ -70,7 +72,7 @@ export async function unlockOnMerge(octokit, context, environment_targets) {
7072
}
7173
}
7274

73-
// if we get here, all locks were made a best effort to be released
75+
// if we get here, all locks had a best effort attempt to be released
7476
core.setOutput('unlocked_environments', releasedEnvironments.join(','))
7577
return true
7678
}

0 commit comments

Comments
 (0)