mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-26 09:02:11 +03:00
* fix(auto): pool accounts by provider model * test(auto): update provider-family-combos to the #7928 Cartesian pool shape Since #7928 the auto-combo candidate pool is a connections × models Cartesian product, so createBuiltinAutoCombo("auto/<family>") now surfaces each backend's full family line-up rather than exactly one default model per connection. The #6453 invariant is unchanged and still asserted — which providers span the family and that unrelated providers (the connected openai/gpt-4o-mini, the connected glm on auto/zai) are excluded — but the two exact-count assertions are relaxed to the provider SET and the detectModelFamily() family check, matching the pattern the sibling auto/minimax case already uses. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --------- Co-authored-by: Your Name <you@example.com> Co-authored-by: adrianaryaputra <adrian.arya@gmail.com> Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
73 lines
2.3 KiB
TypeScript
73 lines
2.3 KiB
TypeScript
/**
|
|
* #7819 (Level 2) — pure `filterExcludedCandidates` unit tests
|
|
* (`open-sse/services/autoCombo/candidateOverrides.ts`). No DB, no network —
|
|
* mirrors the style of `paidModelFilter.ts`'s own tests.
|
|
*/
|
|
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { filterExcludedCandidates } from "../../open-sse/services/autoCombo/candidateOverrides.ts";
|
|
|
|
const pool = [
|
|
{ connectionId: "conn-a", model: "gpt" },
|
|
{ connectionId: "conn-b", model: "claude" },
|
|
{ connectionId: "conn-c", model: "gemini" },
|
|
];
|
|
|
|
test("#7819: empty exclusion set returns the SAME array reference (identity, no-op path)", () => {
|
|
const result = filterExcludedCandidates(pool, new Set());
|
|
assert.strictEqual(result, pool);
|
|
});
|
|
|
|
test("#7819: excluding one connection removes only that candidate", () => {
|
|
const result = filterExcludedCandidates(pool, new Set(["conn-b"]));
|
|
assert.deepEqual(
|
|
result.map((c) => c.connectionId),
|
|
["conn-a", "conn-c"]
|
|
);
|
|
});
|
|
|
|
test("#7819: excluding an unknown connection id leaves the pool unchanged in content", () => {
|
|
const result = filterExcludedCandidates(pool, new Set(["conn-does-not-exist"]));
|
|
assert.deepEqual(
|
|
result.map((c) => c.connectionId),
|
|
["conn-a", "conn-b", "conn-c"]
|
|
);
|
|
});
|
|
|
|
test("#7819: excluding every candidate yields an empty pool (caller's empty-pool path handles it)", () => {
|
|
const result = filterExcludedCandidates(pool, new Set(["conn-a", "conn-b", "conn-c"]));
|
|
assert.equal(result.length, 0);
|
|
});
|
|
|
|
test("#7819: logical candidates retain only non-excluded account fallbacks", () => {
|
|
const logicalPool = [
|
|
{
|
|
connectionId: null,
|
|
allowedConnectionIds: ["conn-a", "conn-b"],
|
|
model: "claude",
|
|
},
|
|
];
|
|
|
|
const result = filterExcludedCandidates(logicalPool, new Set(["conn-a"]));
|
|
assert.deepEqual(result, [
|
|
{
|
|
connectionId: null,
|
|
allowedConnectionIds: ["conn-b"],
|
|
model: "claude",
|
|
},
|
|
]);
|
|
});
|
|
|
|
test("#7819: logical candidates are removed when every account fallback is excluded", () => {
|
|
const logicalPool = [
|
|
{
|
|
connectionId: null,
|
|
allowedConnectionIds: ["conn-a", "conn-b"],
|
|
model: "claude",
|
|
},
|
|
];
|
|
|
|
const result = filterExcludedCandidates(logicalPool, new Set(["conn-a", "conn-b"]));
|
|
assert.deepEqual(result, []);
|
|
});
|