-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy patherrors.test.ts
More file actions
35 lines (30 loc) · 1.02 KB
/
errors.test.ts
File metadata and controls
35 lines (30 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* @vitest-environment node
*/
import { describe, expect, it } from 'vitest'
import { getOpenCodeRouteError } from '@/lib/opencode/errors'
describe('getOpenCodeRouteError', () => {
it('does not leak the internal OpenCode base URL in connectivity errors', () => {
const error = getOpenCodeRouteError(
new Error('fetch failed for http://opencode:4096/session'),
'repositories'
)
expect(error).toEqual({
status: 503,
message:
'OpenCode server is unreachable. Check OPENCODE_BASE_URL and the runtime network configuration.',
})
expect(error.message).not.toContain('http://opencode:4096')
})
it('prioritizes connectivity errors over auth substring matches', () => {
const error = getOpenCodeRouteError(
new Error('fetch failed for http://127.0.0.1:4013/session'),
'repositories'
)
expect(error).toEqual({
status: 503,
message:
'OpenCode server is unreachable. Check OPENCODE_BASE_URL and the runtime network configuration.',
})
})
})