Refactor GitHub repository execution setup

This commit is contained in:
Jinjing
2026-07-19 18:06:08 -07:00
parent 1e9c3cfafa
commit dbd71e41b2
4 changed files with 180 additions and 110 deletions
+29 -1
View File
@@ -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: {}
})
})
})