test: snapshot logging config env

This commit is contained in:
Shakker
2026-06-05 01:10:34 +01:00
parent 28737a0b09
commit abc00f4c98
+3 -6
View File
@@ -3,10 +3,11 @@ import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { afterEach, describe, expect, it } from "vitest";
import { captureEnv } from "../test-utils/env.js";
import { readLoggingConfig } from "./config.js";
const originalArgv = process.argv;
const originalConfigPath = process.env.OPENCLAW_CONFIG_PATH;
const originalEnv = captureEnv(["OPENCLAW_CONFIG_PATH"]);
let tempDirs: string[] = [];
function writeConfig(source: string): string {
@@ -21,11 +22,7 @@ function writeConfig(source: string): string {
describe("readLoggingConfig", () => {
afterEach(() => {
process.argv = originalArgv;
if (originalConfigPath === undefined) {
delete process.env.OPENCLAW_CONFIG_PATH;
} else {
process.env.OPENCLAW_CONFIG_PATH = originalConfigPath;
}
originalEnv.restore();
for (const dir of tempDirs) {
fs.rmSync(dir, { force: true, recursive: true });
}