mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 11:01:24 +00:00
perf(test): remove resetModules from config/sandbox/message suites
This commit is contained in:
@@ -1,20 +1,9 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { ensureSandboxWorkspaceForSession, resolveSandboxContext } from "./sandbox.js";
|
||||
|
||||
describe("resolveSandboxContext", () => {
|
||||
it("does not sandbox the agent main session in non-main mode", async () => {
|
||||
vi.resetModules();
|
||||
|
||||
const spawn = vi.fn(() => {
|
||||
throw new Error("spawn should not be called");
|
||||
});
|
||||
vi.doMock("node:child_process", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("node:child_process")>();
|
||||
return { ...actual, spawn };
|
||||
});
|
||||
|
||||
const { resolveSandboxContext } = await import("./sandbox.js");
|
||||
|
||||
const cfg: OpenClawConfig = {
|
||||
agents: {
|
||||
defaults: {
|
||||
@@ -31,24 +20,9 @@ describe("resolveSandboxContext", () => {
|
||||
});
|
||||
|
||||
expect(result).toBeNull();
|
||||
expect(spawn).not.toHaveBeenCalled();
|
||||
|
||||
vi.doUnmock("node:child_process");
|
||||
}, 15_000);
|
||||
|
||||
it("does not create a sandbox workspace for the agent main session in non-main mode", async () => {
|
||||
vi.resetModules();
|
||||
|
||||
const spawn = vi.fn(() => {
|
||||
throw new Error("spawn should not be called");
|
||||
});
|
||||
vi.doMock("node:child_process", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("node:child_process")>();
|
||||
return { ...actual, spawn };
|
||||
});
|
||||
|
||||
const { ensureSandboxWorkspaceForSession } = await import("./sandbox.js");
|
||||
|
||||
const cfg: OpenClawConfig = {
|
||||
agents: {
|
||||
defaults: {
|
||||
@@ -65,25 +39,9 @@ describe("resolveSandboxContext", () => {
|
||||
});
|
||||
|
||||
expect(result).toBeNull();
|
||||
expect(spawn).not.toHaveBeenCalled();
|
||||
|
||||
vi.doUnmock("node:child_process");
|
||||
}, 15_000);
|
||||
|
||||
it("treats main session aliases as main in non-main mode", async () => {
|
||||
vi.resetModules();
|
||||
|
||||
const spawn = vi.fn(() => {
|
||||
throw new Error("spawn should not be called");
|
||||
});
|
||||
vi.doMock("node:child_process", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("node:child_process")>();
|
||||
return { ...actual, spawn };
|
||||
});
|
||||
|
||||
const { ensureSandboxWorkspaceForSession, resolveSandboxContext } =
|
||||
await import("./sandbox.js");
|
||||
|
||||
const cfg: OpenClawConfig = {
|
||||
session: { mainKey: "work" },
|
||||
agents: {
|
||||
@@ -125,9 +83,5 @@ describe("resolveSandboxContext", () => {
|
||||
workspaceDir: "/tmp/openclaw-test",
|
||||
}),
|
||||
).toBeNull();
|
||||
|
||||
expect(spawn).not.toHaveBeenCalled();
|
||||
|
||||
vi.doUnmock("node:child_process");
|
||||
}, 15_000);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user