0
1
Fork 0
This commit is contained in:
Björn Brauer 2024-04-01 12:45:37 -04:00 committed by GitHub
commit d0a2fa7e71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,37 @@
import * as github from '@actions/github'
import * as githubApiHelper from '../lib/github-api-helper'
jest.mock('@actions/github')
describe('github-api-helper tests', () => {
describe('github enterprise compatibility', () => {
beforeEach(() => {
process.env.GITHUB_SERVER_URL = 'https://enterprise.git.com'
})
afterEach(() => {
delete process.env.GITHUB_SERVER_URL
})
it('getDefaultBranch should use GITHUB_SERVER_URL to set the baseUrl', async () => {
;(github.getOctokit as jest.Mock).mockImplementation(() => {
return {
rest: {
repos: {
get: jest.fn(() => ({data: {default_branch: 'default-branch'}}))
}
}
}
})
await githubApiHelper.getDefaultBranch('token', 'owner', 'repo')
expect(github.getOctokit).toHaveBeenCalledWith(
'token',
expect.objectContaining({
baseUrl: 'https://enterprise.git.com/api/v3'
})
)
})
})
})

1
dist/index.js vendored
View File

@ -1537,6 +1537,7 @@ const io = __importStar(__nccwpck_require__(7436));
const path = __importStar(__nccwpck_require__(1017));
const retryHelper = __importStar(__nccwpck_require__(2155));
const toolCache = __importStar(__nccwpck_require__(7784));
const url_helper_1 = __nccwpck_require__(9437);
const v4_1 = __importDefault(__nccwpck_require__(824));
const url_helper_1 = __nccwpck_require__(9437);
const IS_WINDOWS = process.platform === 'win32';

View File

@ -6,6 +6,7 @@ import * as io from '@actions/io'
import * as path from 'path'
import * as retryHelper from './retry-helper'
import * as toolCache from '@actions/tool-cache'
import {getServerApiUrl} from './url-helper'
import {default as uuid} from 'uuid/v4'
import {getServerApiUrl} from './url-helper'