mirror of
https://github.com/actions/setup-node.git
synced 2025-02-25 17:15:51 +00:00
check failures fix
This commit is contained in:
parent
7a5031f96f
commit
092c6400ca
@ -173,44 +173,7 @@ describe('main tests', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getNodeVersionFromFile', () => {
|
|
||||||
each`
|
|
||||||
contents | expected
|
|
||||||
${'12'} | ${'12'}
|
|
||||||
${'12.3'} | ${'12.3'}
|
|
||||||
${'12.3.4'} | ${'12.3.4'}
|
|
||||||
${'v12.3.4'} | ${'12.3.4'}
|
|
||||||
${'lts/erbium'} | ${'lts/erbium'}
|
|
||||||
${'lts/*'} | ${'lts/*'}
|
|
||||||
${'nodejs 12.3.4'} | ${'12.3.4'}
|
|
||||||
${'ruby 2.3.4\nnodejs 12.3.4\npython 3.4.5'} | ${'12.3.4'}
|
|
||||||
${''} | ${''}
|
|
||||||
${'unknown format'} | ${'unknown format'}
|
|
||||||
${' 14.1.0 '} | ${'14.1.0'}
|
|
||||||
${'{"volta": {"node": ">=14.0.0 <=17.0.0"}}'}| ${'>=14.0.0 <=17.0.0'}
|
|
||||||
${'{"volta": {"extends": "./package.json"}}'}| ${'18.0.0'}
|
|
||||||
${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'}
|
|
||||||
${'{}'} | ${null}
|
|
||||||
`.it('parses "$contents"', ({contents, expected}) => {
|
|
||||||
const existsSpy = jest.spyOn(fs, 'existsSync');
|
|
||||||
existsSpy.mockImplementation(() => true);
|
|
||||||
|
|
||||||
const readFileSpy = jest.spyOn(fs, 'readFileSync');
|
|
||||||
readFileSpy.mockImplementation(filePath => {
|
|
||||||
if (
|
|
||||||
typeof filePath === 'string' &&
|
|
||||||
path.basename(filePath) === 'package.json'
|
|
||||||
) {
|
|
||||||
// Special case for volta.extends
|
|
||||||
return '{"volta": {"node": "18.0.0"}}';
|
|
||||||
}
|
|
||||||
|
|
||||||
return contents;
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(util.getNodeVersionFromFile('file')).toBe(expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('node-version-file flag', () => {
|
describe('node-version-file flag', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -328,40 +291,5 @@ describe('main tests', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('mirror-url parameter', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
inputs['mirror-url'] = 'https://custom-mirror-url.com';
|
|
||||||
|
|
||||||
validateMirrorUrlSpy = jest.spyOn(main, 'run');
|
|
||||||
validateMirrorUrlSpy.mockImplementation(() => {});
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
validateMirrorUrlSpy.mockRestore();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Read mirror-url if mirror-url is provided', async () => {
|
|
||||||
// Arrange
|
|
||||||
inputs['mirror-url'] = 'https://custom-mirror-url.com';
|
|
||||||
|
|
||||||
// Act
|
|
||||||
await main.run();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(inputs['mirror-url']).toBeDefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw an error if mirror-url is empty', async () => {
|
|
||||||
// Arrange
|
|
||||||
inputs['mirror-url'] = ' ';
|
|
||||||
|
|
||||||
// Mock log and setFailed
|
|
||||||
const logSpy = jest.spyOn(console, 'log').mockImplementation(() => {}); // Mock the log function
|
|
||||||
|
|
||||||
// Act & Assert
|
|
||||||
expect(() => validateMirrorURL(inputs['mirror-url'])).toThrowError(
|
|
||||||
'Mirror URL is empty. Please provide a valid mirror URL.'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -16,6 +16,9 @@ inputs:
|
|||||||
default: false
|
default: false
|
||||||
registry-url:
|
registry-url:
|
||||||
description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN.'
|
description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN.'
|
||||||
|
mirror-url:
|
||||||
|
description: 'Custom mirror URL to download Node.js from (optional)'
|
||||||
|
required: false
|
||||||
scope:
|
scope:
|
||||||
description: 'Optional scope for authenticating against scoped registries. Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/).'
|
description: 'Optional scope for authenticating against scoped registries. Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/).'
|
||||||
token:
|
token:
|
||||||
|
Loading…
Reference in New Issue
Block a user