|
|
|
@ -209,3 +209,41 @@ describe('isCacheFeatureAvailable', () => {
|
|
|
|
|
expect(warningSpy).toHaveBeenCalledWith(warningMessage);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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 () => {
|
|
|
|
|
delete process.env['GITHUB_SERVER_URL'];
|
|
|
|
|
expect(cacheUtils.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(cacheUtils.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(cacheUtils.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(cacheUtils.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(cacheUtils.isGhes()).toBeTruthy();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|