another test
This commit is contained in:
parent
241a335117
commit
6cb99a33d7
|
@ -108,6 +108,38 @@ describe('setup-go', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('reports a failed download', async () => {
|
||||||
|
let errMsg = 'unhandled download message';
|
||||||
|
platSpy.mockImplementation(() => 'linux');
|
||||||
|
archSpy.mockImplementation(() => 'x64');
|
||||||
|
|
||||||
|
inSpy.mockImplementation(() => '1.13.1');
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
dlSpy.mockImplementation(() => {
|
||||||
|
throw new Error(errMsg);
|
||||||
|
});
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::error::Failed to download version 1.13.1: Error: ${errMsg}${os.EOL}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reports empty query results', async () => {
|
||||||
|
let errMsg = 'unhandled download message';
|
||||||
|
platSpy.mockImplementation(() => 'linux');
|
||||||
|
archSpy.mockImplementation(() => 'x64');
|
||||||
|
|
||||||
|
inSpy.mockImplementation(() => '1.13.1');
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
getSpy.mockImplementation(() => null);
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::error::Failed to download version 1.13.1: Error: golang download url did not return results${os.EOL}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('can query versions', async () => {
|
it('can query versions', async () => {
|
||||||
let versions: im.IGoVersion[] | null = await im.getVersions(
|
let versions: im.IGoVersion[] | null = await im.getVersions(
|
||||||
'https://non.existant.com/path'
|
'https://non.existant.com/path'
|
||||||
|
|
|
@ -4617,7 +4617,7 @@ function findMatch(versionSpec, stable) {
|
||||||
const dlUrl = 'https://golang.org/dl/?mode=json&include=all';
|
const dlUrl = 'https://golang.org/dl/?mode=json&include=all';
|
||||||
let candidates = yield module.exports.getVersions(dlUrl);
|
let candidates = yield module.exports.getVersions(dlUrl);
|
||||||
if (!candidates) {
|
if (!candidates) {
|
||||||
throw new Error(`golang download url did not return results: ${dlUrl}`);
|
throw new Error(`golang download url did not return results`);
|
||||||
}
|
}
|
||||||
let goFile;
|
let goFile;
|
||||||
for (let i = 0; i < candidates.length; i++) {
|
for (let i = 0; i < candidates.length; i++) {
|
||||||
|
@ -4656,8 +4656,7 @@ function getVersions(dlUrl) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// this returns versions descending so latest is first
|
// this returns versions descending so latest is first
|
||||||
let http = new httpm.HttpClient('setup-go');
|
let http = new httpm.HttpClient('setup-go');
|
||||||
let candidates = (yield http.getJson(dlUrl)).result;
|
return (yield http.getJson(dlUrl)).result;
|
||||||
return candidates;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getVersions = getVersions;
|
exports.getVersions = getVersions;
|
||||||
|
|
|
@ -68,7 +68,7 @@ export async function findMatch(
|
||||||
const dlUrl: string = 'https://golang.org/dl/?mode=json&include=all';
|
const dlUrl: string = 'https://golang.org/dl/?mode=json&include=all';
|
||||||
let candidates: IGoVersion[] | null = await module.exports.getVersions(dlUrl);
|
let candidates: IGoVersion[] | null = await module.exports.getVersions(dlUrl);
|
||||||
if (!candidates) {
|
if (!candidates) {
|
||||||
throw new Error(`golang download url did not return results: ${dlUrl}`);
|
throw new Error(`golang download url did not return results`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let goFile: IGoVersionFile | undefined;
|
let goFile: IGoVersionFile | undefined;
|
||||||
|
@ -111,9 +111,5 @@ export async function findMatch(
|
||||||
export async function getVersions(dlUrl: string): Promise<IGoVersion[] | null> {
|
export async function getVersions(dlUrl: string): Promise<IGoVersion[] | null> {
|
||||||
// this returns versions descending so latest is first
|
// this returns versions descending so latest is first
|
||||||
let http: httpm.HttpClient = new httpm.HttpClient('setup-go');
|
let http: httpm.HttpClient = new httpm.HttpClient('setup-go');
|
||||||
let candidates: IGoVersion[] | null = (await http.getJson<IGoVersion[]>(
|
return (await http.getJson<IGoVersion[]>(dlUrl)).result;
|
||||||
dlUrl
|
|
||||||
)).result;
|
|
||||||
|
|
||||||
return candidates;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue