@@ -5,7 +5,7 @@ import nock from 'nock';
55
66import { listEC2Runners } from '../aws/runners' ;
77import * as ghAuth from '../github/auth' ;
8- import { createRunners } from '../scale-runners/scale-up' ;
8+ import { createRunners , getGitHubEnterpriseApiUrl } from '../scale-runners/scale-up' ;
99import { adjust } from './pool' ;
1010
1111const mockOctokit = {
@@ -30,6 +30,7 @@ jest.mock('./../aws/runners', () => ({
3030jest . mock ( './../github/auth' ) ;
3131jest . mock ( './../scale-runners/scale-up' ) ;
3232
33+
3334const mocktokit = Octokit as jest . MockedClass < typeof Octokit > ;
3435const mockedAppAuth = mocked ( ghAuth . createGithubAppAuth , {
3536 shallow : false ,
@@ -167,6 +168,15 @@ beforeEach(() => {
167168
168169describe ( '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