mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
test: isolate npm update smoke env
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
spawnLoggedCommand,
|
||||
} from "../../scripts/e2e/parallels/npm-update-smoke.ts";
|
||||
import type { HostServer, Platform } from "../../scripts/e2e/parallels/types.ts";
|
||||
import { withEnv, withEnvAsync } from "../../src/test-utils/env.js";
|
||||
|
||||
const SCRIPT_PATH = "scripts/e2e/parallels/npm-update-smoke.ts";
|
||||
const GUEST_TRANSPORTS_PATH = "scripts/e2e/parallels/guest-transports.ts";
|
||||
@@ -78,8 +79,6 @@ describe("parallels npm update smoke", () => {
|
||||
},
|
||||
urlFor: (filePath) => `http://127.0.0.1:48123/${path.basename(filePath)}`,
|
||||
};
|
||||
const previousOpenAiKey = process.env.OPENAI_API_KEY;
|
||||
process.env.OPENAI_API_KEY = "test-key";
|
||||
|
||||
class FailingNpmUpdateSmoke extends NpmUpdateSmoke {
|
||||
protected override async makeRunTempDir(prefix: string): Promise<string> {
|
||||
@@ -93,7 +92,7 @@ describe("parallels npm update smoke", () => {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await withEnvAsync({ OPENAI_API_KEY: "test-key" }, async () => {
|
||||
const smoke = new FailingNpmUpdateSmoke({
|
||||
...TEST_AUTH,
|
||||
json: false,
|
||||
@@ -104,13 +103,7 @@ describe("parallels npm update smoke", () => {
|
||||
});
|
||||
|
||||
await expect(smoke.run()).rejects.toThrow("forced wrapper failure");
|
||||
} finally {
|
||||
if (previousOpenAiKey === undefined) {
|
||||
delete process.env.OPENAI_API_KEY;
|
||||
} else {
|
||||
process.env.OPENAI_API_KEY = previousOpenAiKey;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
expect(stopCalls).toBe(1);
|
||||
});
|
||||
@@ -190,22 +183,15 @@ describe("parallels npm update smoke", () => {
|
||||
});
|
||||
|
||||
it("sets platform-aware fresh lane timeouts", () => {
|
||||
const previous = process.env.OPENCLAW_PARALLELS_NPM_UPDATE_FRESH_TIMEOUT_S;
|
||||
try {
|
||||
delete process.env.OPENCLAW_PARALLELS_NPM_UPDATE_FRESH_TIMEOUT_S;
|
||||
withEnv({ OPENCLAW_PARALLELS_NPM_UPDATE_FRESH_TIMEOUT_S: undefined }, () => {
|
||||
expect(freshLaneTimeoutMs("macos")).toBe(75 * 60 * 1000);
|
||||
expect(freshLaneTimeoutMs("linux")).toBe(75 * 60 * 1000);
|
||||
expect(freshLaneTimeoutMs("windows")).toBe(90 * 60 * 1000);
|
||||
});
|
||||
|
||||
process.env.OPENCLAW_PARALLELS_NPM_UPDATE_FRESH_TIMEOUT_S = "3";
|
||||
withEnv({ OPENCLAW_PARALLELS_NPM_UPDATE_FRESH_TIMEOUT_S: "3" }, () => {
|
||||
expect(freshLaneTimeoutMs("macos")).toBe(3000);
|
||||
} finally {
|
||||
if (previous === undefined) {
|
||||
delete process.env.OPENCLAW_PARALLELS_NPM_UPDATE_FRESH_TIMEOUT_S;
|
||||
} else {
|
||||
process.env.OPENCLAW_PARALLELS_NPM_UPDATE_FRESH_TIMEOUT_S = previous;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it.runIf(process.platform !== "win32")("times out fresh lane process groups", async () => {
|
||||
|
||||
Reference in New Issue
Block a user