35 lines
1008 B
JavaScript
35 lines
1008 B
JavaScript
import { test } from 'node:test';
|
|||
|
|
import assert from 'node:assert/strict';
|
||
|
|
import { chat } from '../src/lib/router.js';
|
||
|
|
|
||
|
|
test('review router client disables model fallbacks explicitly', async () => {
|
||
|
|
const originalFetch = globalThis.fetch;
|
||
|
|
let body;
|
||
|
|
globalThis.fetch = async (_url, init) => {
|
||
|
|
body = JSON.parse(init.body);
|
||
|
|
return Response.json({
|
||
|
|
message: { content: '{"axes":{},"overall":90,"grade":"A","findings":[]}' },
|
||
|
|
_shre: { model: 'ollama-remote/qwen2.5-coder:7b' }
|
||
|
|
});
|
||
|
|
};
|
||
|
|
|
||
|
|
try {
|
||
|
|
await chat({
|
||
|
|
routerUrl: 'http://router.test',
|
||
|
|
model: 'ollama-remote/qwen2.5-coder:7b',
|
||
|
|
messages: [{ role: 'user', content: 'review' }],
|
||
|
|
agentId: 'code-reviewer',
|
||
|
|
sessionId: 'review-test',
|
||
|
|
tenantId: 'nirlab',
|
||
|
|
timeoutMs: 1000
|
||
|
|
});
|
||
|
|
} finally {
|
||
|
|
globalThis.fetch = originalFetch;
|
||
|
|
}
|
||
|
|
|
||
|
|
assert.deepEqual(body.fallbackModels, []);
|
||
|
|
assert.equal(body.tools, false);
|
||
|
|
assert.equal(body.raw, true);
|
||
|
|
assert.equal(body.stream, false);
|
||
|
|
});
|