mirror of
https://code.forgejo.org/actions/setup-go
synced 2025-06-14 14:24:11 +02:00
mocked tests work with no internet
This commit is contained in:
parent
cfc658b90a
commit
f4b0281c15
4 changed files with 12343 additions and 10220 deletions
|
@ -56,14 +56,9 @@ export async function findMatch(
|
|||
let platFilter = sys.getPlatform();
|
||||
|
||||
let match: IGoVersion | undefined;
|
||||
|
||||
const dlUrl: string = 'https://golang.org/dl/?mode=json&include=all';
|
||||
|
||||
// this returns versions descending so latest is first
|
||||
let http: httpm.HttpClient = new httpm.HttpClient('setup-go');
|
||||
let candidates: IGoVersion[] | null = (await http.getJson<IGoVersion[]>(
|
||||
dlUrl
|
||||
)).result;
|
||||
|
||||
let candidates: IGoVersion[] | null = await module.exports.getVersions(dlUrl);
|
||||
if (!candidates) {
|
||||
throw new Error(`golang download url did not return results: ${dlUrl}`);
|
||||
}
|
||||
|
@ -98,3 +93,13 @@ export async function findMatch(
|
|||
|
||||
return match;
|
||||
}
|
||||
|
||||
export async function getVersions(dlUrl: string): Promise<IGoVersion[] | null> {
|
||||
// this returns versions descending so latest is first
|
||||
let http: httpm.HttpClient = new httpm.HttpClient('setup-go');
|
||||
let candidates: IGoVersion[] | null = (await http.getJson<IGoVersion[]>(
|
||||
dlUrl
|
||||
)).result;
|
||||
|
||||
return candidates;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue