Files
OmniRoute/tests/unit/proxy-fallback-cache-key.test.ts
Diego Rodrigues de Sa e Souza 7c23dab64d Release v3.8.40
v3.8.40 cycle integration → main. All test gates green (Unit/Integration/Coverage/Node-compat/Quality-Ratchet). The only red check, 'PR Test Policy', is the test-masking heuristic firing on the cumulative ~57-commit release diff (legitimate assert consolidations already reviewed per-PR — Gemini CLI removal #5246, retired GPT models #5280, provider catalog refreshes); overridden with --admin per the documented release-PR convention. CodeQL/SonarQube advisory scans non-blocking; #5278's code already passed CodeQL on main. Homologated on VPS 192.168.0.15 (v3.8.40 healthy).
2026-06-29 08:40:06 -03:00

43 lines
1.2 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import {
clearProxyFallbackCache,
findWorkingProxy,
__setProxyFallbackTestHooks,
} from "../../open-sse/utils/proxyFallback.ts";
test.afterEach(() => {
__setProxyFallbackTestHooks(null);
clearProxyFallbackCache();
});
test("proxy fallback negative cache is scoped by target URL, not only hostname", async () => {
const proxyUrl = "http://127.0.0.1:18080";
const probes: string[] = [];
__setProxyFallbackTestHooks({
getProxyCandidates: async () => [proxyUrl],
testSingleProxy: async (_proxyUrl, targetUrl) => {
probes.push(targetUrl);
return {
ok: targetUrl.endsWith("/v1/chat/completions"),
latencyMs: targetUrl.endsWith("/v1/chat/completions") ? 12 : null,
};
},
});
assert.equal(
await findWorkingProxy("api.example.test", "https://api.example.test/v1/models"),
null
);
assert.equal(
await findWorkingProxy("api.example.test", "https://api.example.test/v1/chat/completions"),
proxyUrl
);
assert.deepEqual(probes, [
"https://api.example.test/v1/models",
"https://api.example.test/v1/chat/completions",
]);
});