mirror of
https://github.com/actions/setup-java.git
synced 2025-04-19 17:36:45 +00:00
add unit test
This commit is contained in:
parent
61e3daf6da
commit
12bd4a4f13
1 changed files with 41 additions and 1 deletions
|
@ -3,7 +3,8 @@ import * as core from '@actions/core';
|
||||||
import {
|
import {
|
||||||
convertVersionToSemver,
|
convertVersionToSemver,
|
||||||
isVersionSatisfies,
|
isVersionSatisfies,
|
||||||
isCacheFeatureAvailable
|
isCacheFeatureAvailable,
|
||||||
|
isGhes
|
||||||
} from '../src/util';
|
} from '../src/util';
|
||||||
|
|
||||||
jest.mock('@actions/cache');
|
jest.mock('@actions/cache');
|
||||||
|
@ -80,3 +81,42 @@ describe('convertVersionToSemver', () => {
|
||||||
expect(actual).toBe(expected);
|
expect(actual).toBe(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('isGhes', () => {
|
||||||
|
const pristineEnv = process.env;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
process.env = { ...pristineEnv };
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
process.env = pristineEnv;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable is not defined', async () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = undefined;
|
||||||
|
expect(isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable is set to github.com', async () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://github.com';
|
||||||
|
expect(isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL', async () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://contoso.ghe.com';
|
||||||
|
expect(isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix', async () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://mock-github.localhost';
|
||||||
|
expect(isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns true when the GITHUB_SERVER_URL environment variable is set to some other URL', async () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://src.onpremise.fabrikam.com';
|
||||||
|
expect(isGhes()).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue