test: snapshot log tail config env

This commit is contained in:
Shakker
2026-06-05 01:15:23 +01:00
parent dc4c9030fc
commit 5c6a501269

View File

@@ -4,9 +4,10 @@ import os from "node:os";
import path from "node:path";
import { afterEach, describe, expect, it } from "vitest";
import { resetLogger, setLoggerOverride } from "../logging.js";
import { captureEnv } from "../test-utils/env.js";
import { readConfiguredLogTail } from "./log-tail.js";
const originalConfigPath = process.env.OPENCLAW_CONFIG_PATH;
const originalEnv = captureEnv(["OPENCLAW_CONFIG_PATH"]);
let tempDirs: string[] = [];
async function makeTempDir(): Promise<string> {
@@ -16,11 +17,7 @@ async function makeTempDir(): Promise<string> {
}
afterEach(async () => {
if (originalConfigPath === undefined) {
delete process.env.OPENCLAW_CONFIG_PATH;
} else {
process.env.OPENCLAW_CONFIG_PATH = originalConfigPath;
}
originalEnv.restore();
setLoggerOverride(null);
resetLogger();
await Promise.all(tempDirs.map((dir) => fs.rm(dir, { force: true, recursive: true })));