test(ci): use public Feishu temp-dir helper

This commit is contained in:
Vincent Koc
2026-06-20 23:32:15 +08:00
parent 29444b26f2
commit b972956173

View File

@@ -2,8 +2,8 @@
import fs from "node:fs/promises";
import path from "node:path";
import { Readable } from "node:stream";
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { createTempDirTracker } from "../../../test/helpers/temp-dir.js";
import { withTempDir } from "openclaw/plugin-sdk/test-env";
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import type { ClawdbotConfig } from "../runtime-api.js";
const createFeishuClientMock = vi.hoisted(() => vi.fn());
@@ -21,7 +21,6 @@ const messageReplyMock = vi.hoisted(() => vi.fn());
const FEISHU_MEDIA_HTTP_TIMEOUT_MS = 120_000;
const emptyConfig: ClawdbotConfig = {};
const tempDirs = createTempDirTracker();
vi.mock("./client.js", () => ({
createFeishuClient: createFeishuClientMock,
@@ -101,24 +100,20 @@ function callData<T>(
async function withIsolatedHome<T>(run: () => Promise<T>): Promise<T> {
const originalHome = process.env.HOME;
const tempHome = tempDirs.make("openclaw-feishu-media-");
try {
process.env.HOME = tempHome;
return await run();
} finally {
if (originalHome === undefined) {
delete process.env.HOME;
} else {
process.env.HOME = originalHome;
return await withTempDir("openclaw-feishu-media-", async (tempHome) => {
try {
process.env.HOME = tempHome;
return await run();
} finally {
if (originalHome === undefined) {
delete process.env.HOME;
} else {
process.env.HOME = originalHome;
}
}
tempDirs.cleanup();
}
});
}
afterEach(() => {
tempDirs.cleanup();
});
describe("sendMediaFeishu msg_type routing", () => {
beforeAll(async () => {
({