mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-25 15:37:32 +00:00
refactor(test): simplify env scoping in exec and usage tests
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { captureEnv } from "../test-utils/env.js";
|
||||
import { withEnvAsync } from "../test-utils/env.js";
|
||||
import { runCommandWithTimeout, shouldSpawnWithShell } from "./exec.js";
|
||||
|
||||
describe("runCommandWithTimeout", () => {
|
||||
@@ -13,9 +13,7 @@ describe("runCommandWithTimeout", () => {
|
||||
});
|
||||
|
||||
it("merges custom env with process.env", async () => {
|
||||
const envSnapshot = captureEnv(["OPENCLAW_BASE_ENV"]);
|
||||
process.env.OPENCLAW_BASE_ENV = "base";
|
||||
try {
|
||||
await withEnvAsync({ OPENCLAW_BASE_ENV: "base" }, async () => {
|
||||
const result = await runCommandWithTimeout(
|
||||
[
|
||||
process.execPath,
|
||||
@@ -31,9 +29,7 @@ describe("runCommandWithTimeout", () => {
|
||||
expect(result.code).toBe(0);
|
||||
expect(result.stdout).toBe("base|ok");
|
||||
expect(result.termination).toBe("exit");
|
||||
} finally {
|
||||
envSnapshot.restore();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("kills command when no output timeout elapses", async () => {
|
||||
|
||||
Reference in New Issue
Block a user