mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
test(permissions): lock the declared error tag as FetchError.code
This commit is contained in:
1 parent
041ca200f1
commit
fa0cde5d51
1 file changed
+15
@@ -392,6 +392,21 @@ describe('OpenCode facade', () => {
|
||||
expect((failure as FetchError).message).toBe('Session not found')
|
||||
})
|
||||
|
||||
it('preserves the declared error tag as FetchError.code', async () => {
|
||||
fetchMock.mockResolvedValue(
|
||||
new Response(
|
||||
JSON.stringify({ _tag: 'PermissionNotFoundError', sessionID: 'ses_1', requestID: 'per_1', message: 'Permission request not found' }),
|
||||
{ status: 404, headers: { 'Content-Type': 'application/json' } },
|
||||
),
|
||||
)
|
||||
|
||||
const failure = await replyPermission('ses_1', 'per_1', 'once').catch((error: unknown) => error)
|
||||
|
||||
expect(failure).toBeInstanceOf(FetchError)
|
||||
expect((failure as FetchError).statusCode).toBe(404)
|
||||
expect((failure as FetchError).code).toBe('PermissionNotFoundError')
|
||||
})
|
||||
|
||||
it('maps a declared V2 conflict error to 409', async () => {
|
||||
fetchMock.mockResolvedValue(
|
||||
new Response(
|
||||
|
||||
Reference in new issue
Block a user