mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 11:54:46 +00:00
* test: remove low-value suites and cases * test: shrink stale timeout baseline after removing cases
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
DaemonProtocolError,
|
|
decodeDaemonResponseError,
|
|
isDaemonEndpointGoneError,
|
|
SessionNotFoundError
|
|
} from './daemon-errors'
|
|
|
|
function socketError(code: string, syscall: string): Error & { code: string; syscall: string } {
|
|
return Object.assign(new Error(`${syscall} ${code}`), { code, syscall })
|
|
}
|
|
|
|
describe('decodeDaemonResponseError', () => {
|
|
it('types the exact legacy session-absence response', () => {
|
|
expect(decodeDaemonResponseError('Session not found: pty-1')).toBeInstanceOf(
|
|
SessionNotFoundError
|
|
)
|
|
})
|
|
|
|
it('keeps unrelated daemon failures non-authoritative', () => {
|
|
expect(decodeDaemonResponseError('proxy failed: Session not found: pty-1')).toBeInstanceOf(
|
|
DaemonProtocolError
|
|
)
|
|
})
|
|
})
|
|
|
|
describe('isDaemonEndpointGoneError', () => {
|
|
it('recognizes a missing Windows named pipe', () => {
|
|
const err = Object.assign(
|
|
new Error('connect ENOENT \\\\?\\pipe\\orca-terminal-host-v30-14cb7f94b511'),
|
|
{ code: 'ENOENT', syscall: 'connect' }
|
|
)
|
|
expect(isDaemonEndpointGoneError(err)).toBe(true)
|
|
})
|
|
|
|
it('recognizes a refused socket', () => {
|
|
expect(isDaemonEndpointGoneError(socketError('ECONNREFUSED', 'connect'))).toBe(true)
|
|
})
|
|
|
|
it('ignores a missing token file, which does not prove the endpoint is gone', () => {
|
|
expect(isDaemonEndpointGoneError(socketError('ENOENT', 'open'))).toBe(false)
|
|
})
|
|
|
|
it('ignores connect failures that are not proof of absence', () => {
|
|
for (const code of ['ETIMEDOUT', 'ECONNRESET', 'EPIPE', 'EACCES']) {
|
|
expect(isDaemonEndpointGoneError(socketError(code, 'connect'))).toBe(false)
|
|
}
|
|
})
|
|
})
|