@@ -5,7 +5,7 @@ import nock from 'nock';
5
5
6
6
import { listEC2Runners } from '../aws/runners' ;
7
7
import * as ghAuth from '../github/auth' ;
8
- import { createRunners } from '../scale-runners/scale-up' ;
8
+ import { createRunners , getGitHubEnterpriseApiUrl } from '../scale-runners/scale-up' ;
9
9
import { adjust } from './pool' ;
10
10
11
11
const mockOctokit = {
@@ -30,6 +30,7 @@ jest.mock('./../aws/runners', () => ({
30
30
jest . mock ( './../github/auth' ) ;
31
31
jest . mock ( './../scale-runners/scale-up' ) ;
32
32
33
+
33
34
const mocktokit = Octokit as jest . MockedClass < typeof Octokit > ;
34
35
const mockedAppAuth = mocked ( ghAuth . createGithubAppAuth , {
35
36
shallow : false ,
@@ -167,6 +168,15 @@ beforeEach(() => {
167
168
168
169
describe ( 'Test simple pool.' , ( ) => {
169
170
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
+ } ) ;
170
180
it ( 'Top up pool with pool size 2 registered.' , async ( ) => {
171
181
await expect ( await adjust ( { poolSize : 3 } ) ) . resolves ;
172
182
expect ( createRunners ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -240,7 +250,10 @@ describe('Test simple pool.', () => {
240
250
241
251
describe ( 'With GHES' , ( ) => {
242
252
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
+ } ) ;
244
257
} ) ;
245
258
246
259
it ( 'Top up if the pool size is set to 5' , async ( ) => {
@@ -256,7 +269,10 @@ describe('Test simple pool.', () => {
256
269
257
270
describe ( 'With Github Data Residency' , ( ) => {
258
271
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
+ } ) ;
260
276
} ) ;
261
277
262
278
it ( 'Top up if the pool size is set to 5' , async ( ) => {
0 commit comments