mirror of
https://github.com/peaceiris/actions-hugo.git
synced 2026-01-24 10:47:28 +01:00
test: Add unit testing (get-latest-version) (#132)
This commit is contained in:
@@ -3,5 +3,7 @@ export enum Tool {
|
||||
Org = 'gohugoio',
|
||||
Repo = 'hugo',
|
||||
CmdName = 'hugo',
|
||||
CmdOptVersion = 'version'
|
||||
CmdOptVersion = 'version',
|
||||
TestVersionLatest = '0.62.2',
|
||||
TestVersionSpec = '0.61.0'
|
||||
}
|
||||
|
||||
@@ -17,18 +17,14 @@ export async function getLatestVersion(
|
||||
repo: string,
|
||||
api: string
|
||||
): Promise<string> {
|
||||
try {
|
||||
const url = getURL(org, repo, api);
|
||||
const response = await fetch(url);
|
||||
const json = await response.json();
|
||||
let latestVersion = '';
|
||||
if (api === 'brew') {
|
||||
latestVersion = json.versions.stable;
|
||||
} else if (api === 'github') {
|
||||
latestVersion = json.tag_name;
|
||||
}
|
||||
return latestVersion;
|
||||
} catch (e) {
|
||||
return e;
|
||||
const url = getURL(org, repo, api);
|
||||
const response = await fetch(url);
|
||||
const json = await response.json();
|
||||
let latestVersion = '';
|
||||
if (api === 'brew') {
|
||||
latestVersion = json.versions.stable;
|
||||
} else if (api === 'github') {
|
||||
latestVersion = json.tag_name;
|
||||
}
|
||||
return latestVersion;
|
||||
}
|
||||
|
||||
@@ -26,11 +26,7 @@ export async function showVersion(
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
result.exitcode = await exec.exec(cmd, args, options);
|
||||
} catch (e) {
|
||||
return e;
|
||||
}
|
||||
result.exitcode = await exec.exec(cmd, args, options);
|
||||
core.debug(`command: ${cmd} ${args}`);
|
||||
core.debug(`exit code: ${result.exitcode}`);
|
||||
core.debug(`stdout: ${result.output}`);
|
||||
|
||||
Reference in New Issue
Block a user