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