
















@@ -2,6 +2,7 @@
22import { afterEach, describe, expect, it } from "vitest";
33import type { ModelDefinitionConfig } from "../config/types.models.js";
44import type { OpenClawConfig } from "../config/types.openclaw.js";
5+import { deleteTestEnvValue, setTestEnvValue } from "../test-utils/env.js";
56import { resolveModelRuntimePolicy } from "./model-runtime-policy.js";
6778const ORIGINAL_BUILD_PRIVATE_QA = process.env.OPENCLAW_BUILD_PRIVATE_QA;
@@ -29,10 +30,10 @@ function restoreEnv(
2930): void {
3031// Tests mutate private QA env gates; restore exact process state after each.
3132if (value == null) {
32-delete process.env[name];
33+deleteTestEnvValue(name);
3334return;
3435}
35-process.env[name] = value;
36+setTestEnvValue(name, value);
3637}
37383839function makeProviderRuntimeConfig(runtime: string): OpenClawConfig {
@@ -56,8 +57,8 @@ afterEach(() => {
56575758describe("resolveModelRuntimePolicy", () => {
5859it("ignores the QA force-runtime override when the private QA gate is unset", () => {
59-delete process.env.OPENCLAW_BUILD_PRIVATE_QA;
60-process.env.OPENCLAW_QA_FORCE_RUNTIME = "openclaw";
60+deleteTestEnvValue("OPENCLAW_BUILD_PRIVATE_QA");
61+setTestEnvValue("OPENCLAW_QA_FORCE_RUNTIME", "openclaw");
61626263expect(
6364resolveModelRuntimePolicy({
@@ -74,8 +75,8 @@ describe("resolveModelRuntimePolicy", () => {
7475it("respects the QA force-runtime override when the private QA gate is set", () => {
7576// The force-runtime override is intentionally gated to private QA builds so
7677// normal users cannot accidentally change model runtime selection via env.
77-process.env.OPENCLAW_BUILD_PRIVATE_QA = "1";
78-process.env.OPENCLAW_QA_FORCE_RUNTIME = "openclaw";
78+setTestEnvValue("OPENCLAW_BUILD_PRIVATE_QA", "1");
79+setTestEnvValue("OPENCLAW_QA_FORCE_RUNTIME", "openclaw");
79808081expect(
8182resolveModelRuntimePolicy({
@@ -90,8 +91,8 @@ describe("resolveModelRuntimePolicy", () => {
9091});
91929293it("ignores invalid QA force-runtime values even when the private QA gate is set", () => {
93-process.env.OPENCLAW_BUILD_PRIVATE_QA = "1";
94-process.env.OPENCLAW_QA_FORCE_RUNTIME = "bogus";
94+setTestEnvValue("OPENCLAW_BUILD_PRIVATE_QA", "1");
95+setTestEnvValue("OPENCLAW_QA_FORCE_RUNTIME", "bogus");
95969697expect(
9798resolveModelRuntimePolicy({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。