updated test cases

This commit is contained in:
Aparna Jyothi 2025-02-24 12:40:37 +05:30
parent e5561a4d32
commit 7a5031f96f
9 changed files with 172 additions and 272 deletions

View file

@ -10,17 +10,7 @@ export default class NightlyNodejs extends BasePrereleaseNodejs {
protected getDistributionUrl(): string {
if (this.nodeInfo.mirrorURL) {
if (this.nodeInfo.mirrorURL != '') {
return this.nodeInfo.mirrorURL;
} else {
if (this.nodeInfo.mirrorURL === '') {
throw new Error(
'Mirror URL is empty. Please provide a valid mirror URL.'
);
} else {
throw new Error('Mirror URL is not a valid');
}
}
return this.nodeInfo.mirrorURL;
} else {
return 'https://nodejs.org/download/nightly';
}

View file

@ -7,17 +7,7 @@ export default class RcBuild extends BaseDistribution {
}
protected getDistributionUrl(): string {
if (this.nodeInfo.mirrorURL) {
if (this.nodeInfo.mirrorURL != '') {
return this.nodeInfo.mirrorURL;
} else {
if (this.nodeInfo.mirrorURL === '') {
throw new Error(
'Mirror URL is empty. Please provide a valid mirror URL.'
);
} else {
throw new Error('Mirror URL is not a valid');
}
}
return this.nodeInfo.mirrorURL;
} else {
return 'https://nodejs.org/download/rc';
}

View file

@ -8,17 +8,7 @@ export default class CanaryBuild extends BasePrereleaseNodejs {
protected getDistributionUrl(): string {
if (this.nodeInfo.mirrorURL) {
if (this.nodeInfo.mirrorURL != '') {
return this.nodeInfo.mirrorURL;
} else {
if (this.nodeInfo.mirrorURL === '') {
throw new Error(
'Mirror URL is empty. Please provide a valid mirror URL.'
);
} else {
throw new Error('Mirror URL is not a valid');
}
}
return this.nodeInfo.mirrorURL;
} else {
return 'https://nodejs.org/download/v8-canary';
}

View file

@ -7,7 +7,11 @@ import * as path from 'path';
import {restoreCache} from './cache-restore';
import {isCacheFeatureAvailable} from './cache-utils';
import {getNodejsDistribution} from './distributions/installer-factory';
import {getNodeVersionFromFile, printEnvDetailsAndSetOutput} from './util';
import {
getNodeVersionFromFile,
printEnvDetailsAndSetOutput,
validateMirrorURL
} from './util';
import {State} from './constants';
export async function run() {
@ -33,12 +37,8 @@ export async function run() {
arch = os.arch();
}
const mirrorURL = core.getInput('mirror-url');
if (mirrorURL === ' ' && mirrorURL === undefined) {
core.error(
'Mirror URL is emptry or undefined. The default mirror URL will be used.'
);
}
const mirrorurl = core.getInput('mirror-url');
const mirrorURL = validateMirrorURL(mirrorurl);
if (version) {
const token = core.getInput('token');
@ -121,6 +121,3 @@ function resolveVersionInput(): string {
return version;
}
export function setupNodeJs(mirrorURL: string) {
throw new Error('Function not implemented.');
}

View file

@ -97,7 +97,13 @@ async function getToolVersion(tool: string, options: string[]) {
return '';
}
}
export function validateMirrorURL(mirrorURL) {
if (mirrorURL === ' ' || mirrorURL.trim() === 'undefined') {
throw new Error('Mirror URL is empty. Please provide a valid mirror URL.');
} else {
return mirrorURL;
}
}
export const unique = () => {
const encountered = new Set();
return (value: unknown): boolean => {