This commit is contained in:
Tobias Gabriel 2024-11-22 08:02:11 +01:00
parent db66857bcd
commit 81d8c17112
2 changed files with 11 additions and 8 deletions

View file

@ -93,7 +93,7 @@ describe('setup-go', () => {
getAllVersionsSpy = jest.spyOn(im, 'getManifest'); getAllVersionsSpy = jest.spyOn(im, 'getManifest');
// httm // httm
httpmGetJsonSpy = jest.spyOn(httpm.HttpClient.prototype, 'getJson') httpmGetJsonSpy = jest.spyOn(httpm.HttpClient.prototype, 'getJson');
// io // io
whichSpy = jest.spyOn(io, 'which'); whichSpy = jest.spyOn(io, 'which');
@ -162,9 +162,7 @@ describe('setup-go', () => {
}); });
it('should return manifest from raw URL if repo fetch fails', async () => { it('should return manifest from raw URL if repo fetch fails', async () => {
getManifestSpy.mockRejectedValue( getManifestSpy.mockRejectedValue(new Error('Fetch failed'));
new Error('Fetch failed')
);
httpmGetJsonSpy.mockResolvedValue({ httpmGetJsonSpy.mockResolvedValue({
result: goTestManifest result: goTestManifest
}); });
@ -812,7 +810,9 @@ describe('setup-go', () => {
getManifestSpy.mockImplementation(() => { getManifestSpy.mockImplementation(() => {
throw new Error('Unable to download manifest'); throw new Error('Unable to download manifest');
}); });
httpmGetJsonSpy.mockRejectedValue(new Error('Unable to download manifest from raw URL')); httpmGetJsonSpy.mockRejectedValue(
new Error('Unable to download manifest from raw URL')
);
getAllVersionsSpy.mockImplementationOnce(() => undefined); getAllVersionsSpy.mockImplementationOnce(() => undefined);
dlSpy.mockImplementation(async () => '/some/temp/path'); dlSpy.mockImplementation(async () => '/some/temp/path');

View file

@ -13,7 +13,6 @@ const MANIFEST_REPO_NAME = 'go-versions';
const MANIFEST_REPO_BRANCH = 'main'; const MANIFEST_REPO_BRANCH = 'main';
const MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`; const MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`;
type InstallationType = 'dist' | 'manifest'; type InstallationType = 'dist' | 'manifest';
export interface IGoVersionFile { export interface IGoVersionFile {
@ -280,7 +279,9 @@ export async function extractGoArchive(archivePath: string): Promise<string> {
return extPath; return extPath;
} }
export async function getManifest(auth: string | undefined): Promise<tc.IToolRelease[]> { export async function getManifest(
auth: string | undefined
): Promise<tc.IToolRelease[]> {
try { try {
return await getManifestFromRepo(auth); return await getManifestFromRepo(auth);
} catch (err) { } catch (err) {
@ -292,7 +293,9 @@ export async function getManifest(auth: string | undefined): Promise<tc.IToolRel
return await getManifestFromURL(); return await getManifestFromURL();
} }
function getManifestFromRepo(auth: string | undefined): Promise<tc.IToolRelease[]> { function getManifestFromRepo(
auth: string | undefined
): Promise<tc.IToolRelease[]> {
core.debug( core.debug(
`Getting manifest from ${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}@${MANIFEST_REPO_BRANCH}` `Getting manifest from ${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}@${MANIFEST_REPO_BRANCH}`
); );