mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
Add SEARXNG_URL runtime override for the built-in SearXNG web-search provider, defaulting to http://localhost:8888/search. Enables Docker and remote SearXNG deployments without changing existing behavior. Co-authored-by: Cursor <cursoragent@cursor.com>
31 lines
1.0 KiB
JavaScript
31 lines
1.0 KiB
JavaScript
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
|
|
const originalSearxngUrl = process.env.SEARXNG_URL;
|
|
|
|
async function loadProvider(url) {
|
|
if (url === undefined) delete process.env.SEARXNG_URL;
|
|
else process.env.SEARXNG_URL = url;
|
|
vi.resetModules();
|
|
return (await import("../../open-sse/providers/registry/searxng.js")).default;
|
|
}
|
|
|
|
afterEach(() => {
|
|
if (originalSearxngUrl === undefined) delete process.env.SEARXNG_URL;
|
|
else process.env.SEARXNG_URL = originalSearxngUrl;
|
|
vi.resetModules();
|
|
});
|
|
|
|
describe("SearXNG provider configuration", () => {
|
|
it("uses SEARXNG_URL when the deployment config supplies one", async () => {
|
|
const provider = await loadProvider("http://searxng:8080/search");
|
|
|
|
expect(provider.searchConfig.baseUrl).toBe("http://searxng:8080/search");
|
|
});
|
|
|
|
it("preserves the loopback default when SEARXNG_URL is unset", async () => {
|
|
const provider = await loadProvider(undefined);
|
|
|
|
expect(provider.searchConfig.baseUrl).toBe("http://localhost:8888/search");
|
|
});
|
|
});
|