mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-21 22:52:19 +03:00
fix(test): narrow this branch to the drifted test expectations
Three other PRs already cover what this one was carrying. #9618 renumbers the colliding ccr_blocks migration, #9632 repairs the malformed aggregator changelog fragment, and #9676 restores the combo module load by implementing the selection helper the import was reaching for, rather than deleting the caller the way this branch did. Keeping any of it here would put two files back on the same migration slot and overwrite a better fix with a worse one. What survives is the part none of them touch. Once the combo barrel loads again, three assertions in the context-window filter suite start failing: they demand that catalog-too-small targets be dropped, while the file's own header and its four neighbouring tests say those targets stay available as runtime fallback. The unresolved import was masking them. A new case pins the output-token limit as a genuine hard requirement so the relaxation cannot drift further. The provider count assertion kept one literal at the old value after the rest of the file moved to 198, so the partition check failed on a sum that was correct.
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
test("combo routing module loads without unresolved symbols", async () => {
|
||||
const combo = await import("../../open-sse/services/combo.ts");
|
||||
|
||||
assert.equal(typeof combo.filterTargetsByRequestCompatibility, "function");
|
||||
assert.equal(typeof combo.handleComboChat, "function");
|
||||
});
|
||||
@@ -1,79 +0,0 @@
|
||||
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";
|
||||
import Database from "better-sqlite3";
|
||||
|
||||
const migrationsDir = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-ccr-migration-"));
|
||||
const originalMigrationsDir = process.env.OMNIROUTE_MIGRATIONS_DIR;
|
||||
process.env.OMNIROUTE_MIGRATIONS_DIR = migrationsDir;
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(migrationsDir, "134_proxy_logs_egress_ip.sql"),
|
||||
"ALTER TABLE proxy_logs ADD COLUMN egress_ip TEXT;"
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.join(migrationsDir, "139_ccr_blocks.sql"),
|
||||
"CREATE TABLE ccr_blocks (principal_id TEXT PRIMARY KEY);"
|
||||
);
|
||||
|
||||
const { runMigrations } = await import("../../src/lib/db/migrationRunner.ts");
|
||||
|
||||
function createLegacyDb(appliedName: string) {
|
||||
const db = new Database(":memory:");
|
||||
db.exec(`
|
||||
CREATE TABLE proxy_logs (id TEXT PRIMARY KEY);
|
||||
CREATE TABLE ccr_blocks (principal_id TEXT PRIMARY KEY);
|
||||
CREATE TABLE _omniroute_migrations (
|
||||
version TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
applied_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
);
|
||||
`);
|
||||
db.prepare("INSERT INTO _omniroute_migrations (version, name) VALUES (?, ?)").run(
|
||||
"134",
|
||||
appliedName
|
||||
);
|
||||
return db;
|
||||
}
|
||||
|
||||
test.after(() => {
|
||||
fs.rmSync(migrationsDir, { recursive: true, force: true });
|
||||
if (originalMigrationsDir === undefined) delete process.env.OMNIROUTE_MIGRATIONS_DIR;
|
||||
else process.env.OMNIROUTE_MIGRATIONS_DIR = originalMigrationsDir;
|
||||
});
|
||||
|
||||
test("renumbered CCR migration frees 134 for proxy_logs on existing databases", () => {
|
||||
const db = createLegacyDb("ccr_blocks");
|
||||
try {
|
||||
assert.equal(runMigrations(db), 1);
|
||||
assert.deepEqual(
|
||||
db.prepare("SELECT version, name FROM _omniroute_migrations ORDER BY version").all(),
|
||||
[
|
||||
{ version: "134", name: "proxy_logs_egress_ip" },
|
||||
{ version: "139", name: "ccr_blocks" },
|
||||
]
|
||||
);
|
||||
const columns = db.prepare("PRAGMA table_info(proxy_logs)").all() as Array<{ name: string }>;
|
||||
assert.ok(columns.some((column) => column.name === "egress_ip"));
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("renumbered CCR migration marks an existing table without recreating it", () => {
|
||||
const db = createLegacyDb("proxy_logs_egress_ip");
|
||||
try {
|
||||
assert.equal(runMigrations(db), 1);
|
||||
assert.deepEqual(
|
||||
db.prepare("SELECT version, name FROM _omniroute_migrations ORDER BY version").all(),
|
||||
[
|
||||
{ version: "134", name: "proxy_logs_egress_ip" },
|
||||
{ version: "139", name: "ccr_blocks" },
|
||||
]
|
||||
);
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
});
|
||||
@@ -70,8 +70,8 @@ describe("migrationRunner/constants — exact small-table snapshots", () => {
|
||||
// ── large tables — count + shape + spot-checks (corruption guard) ─────────────
|
||||
|
||||
describe("migrationRunner/constants — large-table integrity", () => {
|
||||
it("RENAMED_MIGRATION_COMPATIBILITY has 11 well-formed entries", () => {
|
||||
assert.equal(RENAMED_MIGRATION_COMPATIBILITY.length, 11);
|
||||
it("RENAMED_MIGRATION_COMPATIBILITY has 10 well-formed entries", () => {
|
||||
assert.equal(RENAMED_MIGRATION_COMPATIBILITY.length, 10);
|
||||
for (const e of RENAMED_MIGRATION_COMPATIBILITY) {
|
||||
assert.equal(typeof e.fromVersion, "string");
|
||||
assert.equal(typeof e.fromName, "string");
|
||||
@@ -91,12 +91,6 @@ describe("migrationRunner/constants — large-table integrity", () => {
|
||||
// both manifest_routing collisions (052→059 and 056→059) must survive
|
||||
const manifest = RENAMED_MIGRATION_COMPATIBILITY.filter((e) => e.toName === "manifest_routing");
|
||||
assert.deepEqual(manifest.map((e) => e.fromVersion).sort(), ["052", "056"]);
|
||||
assert.deepEqual(RENAMED_MIGRATION_COMPATIBILITY.at(-1), {
|
||||
fromVersion: "134",
|
||||
fromName: "ccr_blocks",
|
||||
toVersion: "139",
|
||||
toName: "ccr_blocks",
|
||||
});
|
||||
});
|
||||
|
||||
it("PHYSICAL_SCHEMA_SENTINELS has 15 well-formed entries incl. the newest 064", () => {
|
||||
|
||||
Reference in New Issue
Block a user