// pgh repo command dispatch — gip authority surface (P6).
// Thin wrappers: assert the right RPC + params reach the daemon client.
import test from 'brittle'
import { run } from '../lib/commands/repo.js'
function fakeClient () {
const calls = []
return {
calls,
async call (method, params) { calls.push({ method, params }); return { ok: true } }
}
}
test('pgh repo writers <name> → repo-list-writers', async (t) => {
const c = fakeClient()
await run(c, ['writers', 'gip-test'])
t.alike(c.calls, [{ method: 'repo-list-writers', params: { name: 'gip-test' } }])
})
test('pgh repo revoke <name> <userId> → repo-revoke-writer', async (t) => {
const c = fakeClient()
await run(c, ['revoke', 'gip-test', 'bob'])
t.alike(c.calls, [{ method: 'repo-revoke-writer', params: { name: 'gip-test', userId: 'bob' } }])
})
test('pgh repo writers requires a name', async (t) => {
const c = fakeClient()
await t.exception(run(c, ['writers']), /usage/)
t.is(c.calls.length, 0)
})
test('pgh repo revoke requires name + userId', async (t) => {
const c = fakeClient()
await t.exception(run(c, ['revoke', 'gip-test']), /usage/)
t.is(c.calls.length, 0)
})
test('pgh repo invite/join still dispatch correctly (regression)', async (t) => {
const c = fakeClient()
await run(c, ['invite', 'gip-test', '--role', 'contributor'])
await run(c, ['join', 'roompair1:xxx'])
t.alike(c.calls, [
{ method: 'create-repo-invite', params: { name: 'gip-test', role: 'contributor' } },
{ method: 'join-repo', params: { invitation: 'roompair1:xxx' } }
])
})