test(behavior): cover config routing and registry seams
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { assertEquals } from 'jsr:@std/assert@^1.0.0';
|
||||
import { ModelRegistry } from '../ts/models/registry.ts';
|
||||
|
||||
Deno.test('ModelRegistry falls back to the built-in catalog when the source is unavailable', async () => {
|
||||
const registry = new ModelRegistry('http://127.0.0.1:9/catalog.json');
|
||||
const catalog = await registry.fetchCatalog(true);
|
||||
|
||||
assertEquals(catalog.version, '1.0');
|
||||
assertEquals(catalog.models.length > 0, true);
|
||||
});
|
||||
|
||||
Deno.test('ModelRegistry reads catalog entries from a local file source', async () => {
|
||||
const filePath = await Deno.makeTempFile({ suffix: '.json' });
|
||||
await Deno.writeTextFile(
|
||||
filePath,
|
||||
JSON.stringify({
|
||||
version: '1.0',
|
||||
generatedAt: '2026-01-01T00:00:00.000Z',
|
||||
models: [
|
||||
{
|
||||
id: 'Qwen/Qwen2.5-7B-Instruct',
|
||||
aliases: ['qwen-local'],
|
||||
engine: 'vllm',
|
||||
source: { repo: 'Qwen/Qwen2.5-7B-Instruct' },
|
||||
capabilities: { chat: true },
|
||||
requirements: { minVramGb: 16 },
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
try {
|
||||
const registry = new ModelRegistry(filePath);
|
||||
const model = await registry.getModel('qwen-local');
|
||||
|
||||
assertEquals(model?.id, 'Qwen/Qwen2.5-7B-Instruct');
|
||||
} finally {
|
||||
await Deno.remove(filePath);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user