Refactor GitHub repository execution setup
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { githubHostExecOptions } from './github-api-repository'
|
||||
import { githubHostExecOptions, resolveGitHubRepoExecution } from './github-api-repository'
|
||||
|
||||
describe('githubHostExecOptions', () => {
|
||||
it('pins every known repository host', () => {
|
||||
@@ -17,3 +17,31 @@ describe('githubHostExecOptions', () => {
|
||||
expect(githubHostExecOptions(null)).toEqual({})
|
||||
})
|
||||
})
|
||||
|
||||
describe('resolveGitHubRepoExecution', () => {
|
||||
it('combines local repository and GitHub host execution options', async () => {
|
||||
const ownerRepo = { owner: 'acme', repo: 'widgets', host: 'github.acme-corp.com' }
|
||||
|
||||
await expect(
|
||||
resolveGitHubRepoExecution('/repo', ownerRepo, null, { wslDistro: 'Ubuntu' })
|
||||
).resolves.toEqual({
|
||||
ownerRepo,
|
||||
ghOptions: {
|
||||
cwd: '/repo',
|
||||
wslDistro: 'Ubuntu',
|
||||
host: 'github.acme-corp.com'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('uses a caller-specific repository resolver without changing its identity', async () => {
|
||||
const ownerRepo = { owner: 'upstream', repo: 'widgets' }
|
||||
|
||||
await expect(
|
||||
resolveGitHubRepoExecution('/remote/repo', async () => ownerRepo, 'ssh-1')
|
||||
).resolves.toEqual({
|
||||
ownerRepo,
|
||||
ghOptions: {}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user