Add isGhes gate and refactor to clean up circular dependencies

This commit is contained in:
Bassem Dghaidi
2024-11-21 04:01:44 -08:00
committed by GitHub
parent ab58a59f33
commit 267841d7bd
8 changed files with 79 additions and 64 deletions

26
packages/cache/__tests__/config.test.ts vendored Normal file
View File

@@ -0,0 +1,26 @@
import { promises as fs } from 'fs'
import * as config from '../src/internal/config'
beforeEach(() => {
jest.resetModules()
})
test('isGhes returns false for github.com', async () => {
process.env.GITHUB_SERVER_URL = 'https://github.com'
expect(config.isGhes()).toBe(false)
})
test('isGhes returns false for ghe.com', async () => {
process.env.GITHUB_SERVER_URL = 'https://somedomain.ghe.com'
expect(config.isGhes()).toBe(false)
})
test('isGhes returns true for enterprise URL', async () => {
process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com'
expect(config.isGhes()).toBe(true)
})
test('isGhes returns false for ghe.localhost', () => {
process.env.GITHUB_SERVER_URL = 'https://my.domain.ghe.localhost'
expect(config.isGhes()).toBe(false)
})