test early exit on a deployment cancel request

This commit is contained in:
grantbirki
2023-04-14 21:20:52 +01:00
parent c38b3699e6
commit 36f9337a64
3 changed files with 16 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ const fakeJwt =
describe('Deployment', () => {
beforeEach(() => {
jest.clearAllMocks()
process.env.ACTIONS_RUNTIME_URL = 'http://my-url/'
process.env.GITHUB_RUN_ID = '123'
process.env.ACTIONS_RUNTIME_TOKEN = 'a-token'
@@ -395,5 +396,18 @@ describe('Deployment', () => {
createDeploymentScope.done()
cancelDeploymentScope.done()
})
it('can exit if a pages deployment was not created and none need to be cancelled', async () => {
process.env.GITHUB_SHA = 'valid-build-version'
// Create the deployment
const deployment = new Deployment()
// Cancel it
await deployment.cancel()
expect(core.debug).toHaveBeenCalledWith('all variables are set')
expect(core.debug).toHaveBeenCalledWith(`No deployment to cancel`)
})
})
})