Skip to content

Commit b9226f6

Browse files
committed
Fix test for pool.ts
1 parent 0d7f193 commit b9226f6

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

lambdas/functions/control-plane/src/pool/pool.test.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import nock from 'nock';
55

66
import { listEC2Runners } from '../aws/runners';
77
import * as ghAuth from '../github/auth';
8-
import { createRunners } from '../scale-runners/scale-up';
8+
import { createRunners, getGitHubEnterpriseApiUrl } from '../scale-runners/scale-up';
99
import { adjust } from './pool';
1010

1111
const mockOctokit = {
@@ -30,6 +30,7 @@ jest.mock('./../aws/runners', () => ({
3030
jest.mock('./../github/auth');
3131
jest.mock('./../scale-runners/scale-up');
3232

33+
3334
const mocktokit = Octokit as jest.MockedClass<typeof Octokit>;
3435
const mockedAppAuth = mocked(ghAuth.createGithubAppAuth, {
3536
shallow: false,
@@ -167,6 +168,15 @@ beforeEach(() => {
167168

168169
describe('Test simple pool.', () => {
169170
describe('With GitHub Cloud', () => {
171+
beforeEach(() => {
172+
getGitHubEnterpriseApiUrl.mockReturnValue({
173+
ghesApiUrl: '',
174+
ghesBaseUrl: '',
175+
});
176+
177+
// Reset mocks before each test
178+
jest.clearAllMocks();
179+
});
170180
it('Top up pool with pool size 2 registered.', async () => {
171181
await expect(await adjust({ poolSize: 3 })).resolves;
172182
expect(createRunners).toHaveBeenCalledTimes(1);
@@ -240,7 +250,10 @@ describe('Test simple pool.', () => {
240250

241251
describe('With GHES', () => {
242252
beforeEach(() => {
243-
process.env.GHES_URL = 'https://github.enterprise.something';
253+
getGitHubEnterpriseApiUrl.mockReturnValue({
254+
ghesApiUrl: 'https://api.github.enterprise.something',
255+
ghesBaseUrl: 'https://github.enterprise.something',
256+
});
244257
});
245258

246259
it('Top up if the pool size is set to 5', async () => {
@@ -256,7 +269,10 @@ describe('Test simple pool.', () => {
256269

257270
describe('With Github Data Residency', () => {
258271
beforeEach(() => {
259-
process.env.GHES_URL = 'https://companyname.ghe.com';
272+
getGitHubEnterpriseApiUrl.mockReturnValue({
273+
ghesApiUrl: 'https://api.companyname.ghe.com',
274+
ghesBaseUrl: 'https://companyname.ghe.com',
275+
});
260276
});
261277

262278
it('Top up if the pool size is set to 5', async () => {

0 commit comments

Comments
 (0)