mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
test: snapshot log tail config env
This commit is contained in:
@@ -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 })));
|
||||
|
||||
Reference in New Issue
Block a user