mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-04 14:22:09 +03:00
Integrated into release/v3.8.0 — batch of 10 feature requests: llama.cpp local provider, upstream error exposure, Termux detection, providers rotate CLI, t3.chat web skeleton, Zed Docker integration, Kiro multi-account OAuth isolation, auto-combo cost blending, auto-combo context filter, combo provider-level exhaustion tracking (#1731). Conflicts with #2417 (falloverBeforeRetry) resolved.
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { isRunningInDocker } from "../../src/lib/zed-oauth/dockerDetect.ts";
|
|
|
|
// Tests use dependency injection (dockerDetect accepts optional `deps`)
|
|
// so no module mocking is required.
|
|
|
|
test("isRunningInDocker returns true when /.dockerenv exists", () => {
|
|
const result = isRunningInDocker({
|
|
existsSync: (p: string) => p === "/.dockerenv",
|
|
readFileSync: (_p: string, _enc: string) => {
|
|
throw new Error("skip");
|
|
},
|
|
});
|
|
assert.equal(result, true);
|
|
});
|
|
|
|
test("isRunningInDocker returns true when /proc/1/cgroup contains 'docker'", () => {
|
|
const result = isRunningInDocker({
|
|
existsSync: (_p: string) => false,
|
|
readFileSync: (_p: string, _enc: string) => "12:cpuset:/docker/abc123\n",
|
|
});
|
|
assert.equal(result, true);
|
|
});
|
|
|
|
test("isRunningInDocker returns false on a plain host environment", () => {
|
|
const result = isRunningInDocker({
|
|
existsSync: (_p: string) => false,
|
|
readFileSync: (_p: string, _enc: string) => "12:cpuset:/\n",
|
|
});
|
|
assert.equal(result, false);
|
|
});
|
|
|
|
test("isRunningInDocker returns false when fs throws for all checks", () => {
|
|
const result = isRunningInDocker({
|
|
existsSync: (_p: string) => {
|
|
throw new Error("EPERM");
|
|
},
|
|
readFileSync: (_p: string, _enc: string) => {
|
|
throw new Error("ENOENT");
|
|
},
|
|
});
|
|
assert.equal(result, false);
|
|
});
|