Files
OpenCode 68a9071cf1 feat: reconcile local master with origin (exa/hot-platform hunters, leaks ledger, latest results)
Local branch had diverged from origin/master (sibling commits on the same base). Rewrote local history linearly on top of origin/master, folding in all local content: exa/hot-platform discovery hunters, leaks ledger, nightly sweep orchestrator, updated .gitignore and skill docs, plus the latest hunt output and vault state. Remote-only files (vault keys, channel scripts) were restored rather than dropped, so the resulting tree is a full union of both sides.
2026-08-07 12:53:47 +08:00

1 line
3.1 KiB
JSON

{"repo": "alexwasheree/notecast", "files": {"src/infrastructure/llm/tests/deepseek.client.test.ts": {"c6307c6e49d87040f43f000be2d40dd597fe86c4": {"t": 1786068275.5560331, "n": 2914, "h": "89380c6dcfdcd2f4", "c": "import { afterEach, beforeEach, describe, expect, test } from 'bun:test';\nimport { DeepSeekClient } from '../clients/deepseek.client';\n\nlet originalFetch: typeof fetch;\n\nbeforeEach(() => {\n originalFetch = global.fetch;\n});\nafterEach(() => {\n global.fetch = originalFetch;\n delete process.env.DEEPSEEK_API_KEY;\n});\n\nfunction mockFetch(body: unknown, status = 200) {\n global.fetch = async () =>\n new Response(JSON.stringify(body), {\n status,\n headers: { 'Content-Type': 'application/json' },\n });\n}\n\ndescribe('DeepSeekClient', () => {\n test('returns text from choices', async () => {\n mockFetch({ choices: [{ message: { content: 'hello from deepseek' } }] });\n const client = new DeepSeekClient('test-key');\n const result = await client.chat('say hello', { instructions: 'be brief' });\n expect(result).toBe('hello from deepseek');\n });\n\n test('uses default model deepseek-chat', async () => {\n let capturedBody: Record<string, unknown> = {};\n global.fetch = async (_url, init) => {\n capturedBody = JSON.parse(init?.body as string);\n return new Response(JSON.stringify({ choices: [{ message: { content: 'ok' } }] }), {\n status: 200,\n });\n };\n const client = new DeepSeekClient('test-key');\n await client.chat('test');\n expect(capturedBody.model).toBe('deepseek-chat');\n });\n\n test('throws on 401', async () => {\n mockFetch({ error: { message: 'invalid api key' } }, 401);\n const client = new DeepSeekClient('bad-key');\n await expect(client.chat('test')).rejects.toThrow('is invalid');\n });\n\n test('throws on 402 (insufficient balance)', async () => {\n mockFetch({ error: { message: 'insufficient balance' } }, 402);\n const client = new DeepSeekClient('test-key');\n await expect(client.chat('test')).rejects.toThrow('is invalid');\n });\n\n test('sends response_format json_object when responseFormat is json', async () => {\n let capturedBody: Record<string, unknown> = {};\n global.fetch = async (_url, init) => {\n capturedBody = JSON.parse(init?.body as string);\n return new Response(JSON.stringify({ choices: [{ message: { content: '{\"ok\":true}' } }] }), {\n status: 200,\n });\n };\n const client = new DeepSeekClient('test-key');\n await client.chat('return json', { responseFormat: 'json' });\n expect(capturedBody.response_format).toEqual({ type: 'json_object' });\n });\n\n test('omits response_format when responseFormat is not set', async () => {\n let capturedBody: Record<string, unknown> = {};\n global.fetch = async (_url, init) => {\n capturedBody = JSON.parse(init?.body as string);\n return new Response(JSON.stringify({ choices: [{ message: { content: 'hello' } }] }), {\n status: 200,\n });\n };\n const client = new DeepSeekClient('test-key');\n await client.chat('test');\n expect(capturedBody.response_format).toBeUndefined();\n });\n});\n"}}}}