
















1+// Test Live Models Docker tests cover direct live model Docker script behavior.
2+import { spawnSync } from "node:child_process";
3+import fs from "node:fs";
4+import path from "node:path";
5+import { describe, expect, it } from "vitest";
6+7+const SCRIPT_PATH = path.resolve(import.meta.dirname, "../../scripts/test-live-models-docker.sh");
8+9+describe("scripts/test-live-models-docker.sh", () => {
10+it("validates optional live model limits before auth or Docker setup", () => {
11+const script = fs.readFileSync(SCRIPT_PATH, "utf8");
12+13+expect(script).toContain('LIVE_MAX_MODELS="${OPENCLAW_LIVE_MAX_MODELS:-}"');
14+expect(script).toContain('[[ -n "$LIVE_MAX_MODELS" && ! "$LIVE_MAX_MODELS" =~ ^\\+?[0-9]+$ ]]');
15+expect(script).toContain(
16+'openclaw_live_read_positive_int_env OPENCLAW_LIVE_MODEL_TIMEOUT_MS "$LIVE_MODEL_TIMEOUT_MS"',
17+);
18+expect(script).toContain('-e OPENCLAW_LIVE_MAX_MODELS="$LIVE_MAX_MODELS"');
19+expect(script).toContain('-e OPENCLAW_LIVE_MODEL_TIMEOUT_MS="$LIVE_MODEL_TIMEOUT_MS"');
20+});
21+22+it.each([
23+["max models", "OPENCLAW_LIVE_MAX_MODELS", "3models"],
24+["model timeout", "OPENCLAW_LIVE_MODEL_TIMEOUT_MS", "45s"],
25+])("rejects invalid %s values before live Docker setup", (_label, envName, value) => {
26+const result = spawnSync("bash", [SCRIPT_PATH], {
27+encoding: "utf8",
28+env: {
29+ ...process.env,
30+[envName]: value,
31+},
32+});
33+34+expect(result.status).toBe(2);
35+expect(result.stderr).toContain(`invalid ${envName}: ${value}`);
36+expect(result.stderr).not.toContain("docker");
37+expect(result.stderr).not.toContain("Cannot find package 'tsx'");
38+});
39+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。