tests(withdeploy): add tests for withdeploy
Some checks failed
Check Transpiled JavaScript / Check dist/ (push) Successful in 43s
Continuous Integration / TypeScript Tests (push) Failing after 56s
Continuous Integration / GitHub Actions Test (push) Failing after 6s
Renovate / renovate (push) Successful in 53s

This commit is contained in:
Peter 2024-11-27 20:40:51 +01:00
parent 35de0fc568
commit a7950b9ce3
Signed by: prskr
GPG key ID: F56BED6903BC5E37
4 changed files with 41 additions and 10 deletions

View file

@ -29,4 +29,32 @@ describe('Install Hugo', () => {
}) })
).not.toThrow() ).not.toThrow()
}, 30_000) }, 30_000)
test('Download latest Hugo - extended', async () => {
const releaseLookup = new OctokitReleaseLookup()
const platformMock = new Platform('linux', undefined, { HOME: tmpDir })
const hugo = new HugoInstaller(releaseLookup, platformMock)
expect(
async () =>
await hugo.install({
version: 'latest',
extended: true
})
).not.toThrow()
}, 30_000)
test('Download latest Hugo - with deploy', async () => {
const releaseLookup = new OctokitReleaseLookup()
const platformMock = new Platform('linux', undefined, { HOME: tmpDir })
const hugo = new HugoInstaller(releaseLookup, platformMock)
expect(
async () =>
await hugo.install({
version: 'latest',
withDeploy: true
})
).not.toThrow()
}, 30_000)
}) })

8
dist/index.js vendored
View file

@ -50817,10 +50817,10 @@ class HugoInstaller {
const tmpDir = external_node_os_namespaceObject.tmpdir(); const tmpDir = external_node_os_namespaceObject.tmpdir();
let versionSpec = release.tag_name; let versionSpec = release.tag_name;
if (cmd.extended) { if (cmd.extended) {
versionSpec += '+extended'; versionSpec = `${release.tag_name}+extended`;
} }
if (cmd.withDeploy) { else if (cmd.withDeploy) {
versionSpec += '+withdeploy'; versionSpec = `${release.tag_name}+extended+withdeploy`;
} }
try { try {
const cachedTool = tool_cache.find(Hugo.Name, versionSpec, this.platform.arch); const cachedTool = tool_cache.find(Hugo.Name, versionSpec, this.platform.arch);
@ -50832,7 +50832,7 @@ class HugoInstaller {
catch (e) { catch (e) {
core.warning(`Failed to lookup tool in cache: ${errorMsg(e)}`); core.warning(`Failed to lookup tool in cache: ${errorMsg(e)}`);
} }
const toolUrl = release.assetUrl(this.platform, cmd.extended); const toolUrl = release.assetUrl(this.platform, cmd.extended, cmd.withDeploy);
if (!toolUrl) { if (!toolUrl) {
throw new Error('No matching URL detected for given platform'); throw new Error('No matching URL detected for given platform');
} }

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -43,10 +43,9 @@ export class HugoInstaller {
let versionSpec = release.tag_name let versionSpec = release.tag_name
if (cmd.extended) { if (cmd.extended) {
versionSpec += '+extended' versionSpec = `${release.tag_name}+extended`
} } else if (cmd.withDeploy) {
if (cmd.withDeploy) { versionSpec = `${release.tag_name}+extended+withdeploy`
versionSpec += '+withdeploy'
} }
try { try {
@ -59,7 +58,11 @@ export class HugoInstaller {
core.warning(`Failed to lookup tool in cache: ${errorMsg(e)}`) core.warning(`Failed to lookup tool in cache: ${errorMsg(e)}`)
} }
const toolUrl = release.assetUrl(this.platform, cmd.extended) const toolUrl = release.assetUrl(
this.platform,
cmd.extended,
cmd.withDeploy
)
if (!toolUrl) { if (!toolUrl) {
throw new Error('No matching URL detected for given platform') throw new Error('No matching URL detected for given platform')