mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-22 23:22:09 +03:00
Reconciliado com a release (mesmo drift de typecheck-baseline/glm.ts/fetchTimeout.ts/stryker.conf.json dos PRs irmãos) e corrigi o `no-explicit-any` no teste novo (cast tipado, mesmo padrão do repo). Validado: lint limpo, teste focado passando. Fix real (busca de credenciais opencode-zen/opencode via PROVIDER_SEARCH_PAIRS). CI vermelho é o base-red já rastreado em #9985. Obrigado!
30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-opencode-pair-test-"));
|
|
process.env.DATA_DIR = TEST_DATA_DIR;
|
|
process.env.API_KEY_SECRET = process.env.API_KEY_SECRET || "opencode-pair-test-secret";
|
|
|
|
const core = await import("../../src/lib/db/core.ts");
|
|
const { getProviderCredentials } = await import("../../src/sse/services/auth.ts");
|
|
|
|
test("getProviderCredentials('opencode-zen') finds active connection stored under 'opencode'", async () => {
|
|
const db = core.getDbInstance();
|
|
const now = new Date().toISOString();
|
|
|
|
// Seed an active connection under provider='opencode'
|
|
db.prepare(
|
|
`INSERT OR REPLACE INTO provider_connections
|
|
(id, provider, is_active, api_key, created_at, updated_at)
|
|
VALUES (?, ?, ?, ?, ?, ?)`
|
|
).run("opencode-conn-1", "opencode", 1, "test-opencode-key", now, now);
|
|
|
|
const creds = (await getProviderCredentials("opencode-zen")) as { apiKey?: string } | null;
|
|
|
|
assert.ok(creds, "Credentials should be returned for opencode-zen lookup");
|
|
assert.equal(creds!.apiKey, "test-opencode-key");
|
|
});
|