mirror of
https://code.forgejo.org/actions/setup-node
synced 2025-06-19 18:10:26 +02:00
code improvements
This commit is contained in:
parent
30c33f0409
commit
5d5d8e9b58
4 changed files with 51 additions and 16 deletions
|
@ -13,6 +13,7 @@ import each from 'jest-each';
|
|||
import * as main from '../src/main';
|
||||
import * as util from '../src/util';
|
||||
import OfficialBuilds from '../src/distributions/official_builds/official_builds';
|
||||
import { validateMirrorURL } from '../src/util';
|
||||
|
||||
describe('main tests', () => {
|
||||
let inputs = {} as any;
|
||||
|
@ -280,4 +281,40 @@ describe('main tests', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
describe('mirror-url parameter', () => {
|
||||
beforeEach(() => {
|
||||
inputs['mirror-url'] = 'https://custom-mirror-url.com';
|
||||
|
||||
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete inputs['mirror-url'];
|
||||
});
|
||||
|
||||
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'])).toThrow(
|
||||
'Mirror URL is empty. Please provide a valid mirror URL.'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue