mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 05:12:15 +00:00
test: stop leaking image workspace temp dirs
This commit is contained in:
@@ -88,8 +88,10 @@ const ONE_PIXEL_JPEG_B64 = "QUJDRA==";
|
||||
|
||||
async function withTempWorkspacePng(
|
||||
cb: (args: { workspaceDir: string; imagePath: string }) => Promise<void>,
|
||||
options?: { parentDir?: string },
|
||||
) {
|
||||
const workspaceParent = await fs.mkdtemp(path.join(process.cwd(), ".openclaw-workspace-image-"));
|
||||
const parentDir = options?.parentDir ?? os.tmpdir();
|
||||
const workspaceParent = await fs.mkdtemp(path.join(parentDir, "openclaw-workspace-image-"));
|
||||
try {
|
||||
const workspaceDir = path.join(workspaceParent, "workspace");
|
||||
await fs.mkdir(workspaceDir, { recursive: true });
|
||||
@@ -715,13 +717,13 @@ describe("image tool implicit imageModel config", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("allows workspace images via createOpenClawCodingTools default workspace root", async () => {
|
||||
await withTempWorkspacePng(async ({ imagePath }) => {
|
||||
it("allows workspace images via createOpenClawCodingTools when workspace root is explicit", async () => {
|
||||
await withTempWorkspacePng(async ({ workspaceDir, imagePath }) => {
|
||||
const fetch = stubMinimaxOkFetch();
|
||||
await withTempAgentDir(async (agentDir) => {
|
||||
const cfg = createMinimaxImageConfig();
|
||||
|
||||
const tools = createOpenClawCodingTools({ config: cfg, agentDir });
|
||||
const tools = createOpenClawCodingTools({ config: cfg, agentDir, workspaceDir });
|
||||
const tool = requireImageTool(tools.find((candidate) => candidate.name === "image"));
|
||||
|
||||
await expectImageToolExecOk(tool, imagePath);
|
||||
|
||||
Reference in New Issue
Block a user