mocked tests work with no internet

This commit is contained in:
Bryan MacFarlane
2020-02-09 09:25:20 -05:00
parent cfc658b90a
commit f4b0281c15
4 changed files with 12343 additions and 10220 deletions

View File

@ -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;
}