Add extra test

This commit is contained in:
Konrad Pabjan
2023-10-30 15:35:32 -04:00
parent a075a5970d
commit 4279385f7d
4 changed files with 26 additions and 3 deletions

5
dist/index.js generated vendored
View File

@@ -9660,7 +9660,10 @@ async function getArtifactMetadata({ githubToken, runId, artifactName }) {
size: artifactSize size: artifactSize
} }
} catch (error) { } catch (error) {
core.error('Fetching artifact metadata failed', error) core.error(
'Fetching artifact metadata failed. Is githubstatus.com reporting issues with API requests, Pages or Actions? Please re-run the deployment at a later time.',
error
)
throw error throw error
} }
} }

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -320,6 +320,23 @@ describe('Deployment', () => {
artifactMetadataScope.done() artifactMetadataScope.done()
}) })
it('fails with error message if list artifact endpoint returns 500', async () => {
process.env.GITHUB_SHA = 'valid-build-version'
const artifactMetadataScope = nock(`https://api.github.com`)
.get(
`/repos/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/artifacts?name=github-pages`
)
.reply(500, { message: 'oh no' })
const deployment = new Deployment()
await expect(deployment.create(fakeJwt)).rejects.toThrow(
`Failed to create deployment (status: 500) with build version valid-build-version. Server error, is githubstatus.com reporting a Pages outage? Please re-run the deployment at a later time.`
)
artifactMetadataScope.done()
})
it('warns if the artifact size is bigger than maximum', async () => { it('warns if the artifact size is bigger than maximum', async () => {
process.env.GITHUB_SHA = 'valid-build-version' process.env.GITHUB_SHA = 'valid-build-version'
const artifactSize = ONE_GIGABYTE + 1 const artifactSize = ONE_GIGABYTE + 1

View File

@@ -43,7 +43,10 @@ async function getArtifactMetadata({ githubToken, runId, artifactName }) {
size: artifactSize size: artifactSize
} }
} catch (error) { } catch (error) {
core.error('Fetching artifact metadata failed', error) core.error(
'Fetching artifact metadata failed. Is githubstatus.com reporting issues with API requests, Pages or Actions? Please re-run the deployment at a later time.',
error
)
throw error throw error
} }
} }