1
0
Fork 0

formatting fixes

pull/1646/head
eggyhead 2024-01-31 01:58:42 +00:00
parent b680ef8e68
commit 4efc4b9e06
4 changed files with 23 additions and 25 deletions

View File

@ -1,25 +1,22 @@
import * as config from '../src/internal/shared/config' import * as config from '../src/internal/shared/config'
beforeEach(() => { beforeEach(() => {
jest.resetModules() jest.resetModules()
}); })
describe('isGhes', () => { describe('isGhes', () => {
it('should return false when the request domain is github.com', () => { it('should return false when the request domain is github.com', () => {
process.env.GITHUB_SERVER_URL = 'https://github.com' process.env.GITHUB_SERVER_URL = 'https://github.com'
expect(config.isGhes()).toBe(false) expect(config.isGhes()).toBe(false)
}) })
it('should return false when the request has ACTIONS_RESULTS_URL set', () => { it('should return false when the request has ACTIONS_RESULTS_URL set', () => {
process.env.ACTIONS_RESULTS_URL = 'my.results.url' process.env.ACTIONS_RESULTS_URL = 'my.results.url'
expect(config.isGhes()).toBe(false) expect(config.isGhes()).toBe(false)
}) })
it('should return false when the request domain is specific to an enterprise', () => {
it('should return false when the request domain is specific to an enterprise', () => { process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com'
process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com' expect(config.isGhes()).toBe(true)
expect(config.isGhes()).toBe(true) })
}) })
})

View File

@ -27,10 +27,11 @@ export function isGhes(): boolean {
const ghUrl = new URL( const ghUrl = new URL(
process.env['GITHUB_SERVER_URL'] || 'https://github.com' process.env['GITHUB_SERVER_URL'] || 'https://github.com'
) )
const isGitHubHost = (ghUrl.hostname.trimEnd().toUpperCase() === 'GITHUB.COM') const isGitHubHost = ghUrl.hostname.trimEnd().toUpperCase() === 'GITHUB.COM'
const isResultsServiceRequest = process.env['ACTIONS_RESULTS_URL'] != undefined const isResultsServiceRequest =
process.env['ACTIONS_RESULTS_URL'] != undefined
return !isGitHubHost && !isResultsServiceRequest return !isGitHubHost && !isResultsServiceRequest
} }

View File

@ -3,8 +3,8 @@ import * as path from 'path'
import * as cacheUtils from '../src/internal/cacheUtils' import * as cacheUtils from '../src/internal/cacheUtils'
beforeEach(() => { beforeEach(() => {
jest.resetModules() jest.resetModules()
}); })
test('getArchiveFileSizeInBytes returns file size', () => { test('getArchiveFileSizeInBytes returns file size', () => {
const filePath = path.join(__dirname, '__fixtures__', 'helloWorld.txt') const filePath = path.join(__dirname, '__fixtures__', 'helloWorld.txt')

View File

@ -129,4 +129,4 @@ export function isGhes(): boolean {
process.env['GITHUB_SERVER_URL'] || 'https://github.com' process.env['GITHUB_SERVER_URL'] || 'https://github.com'
) )
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM' return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'
} }