mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:09:34 +00:00
refactor(test): reuse env snapshot helper
This commit is contained in:
18
src/test-utils/env.ts
Normal file
18
src/test-utils/env.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export function captureEnv(keys: string[]) {
|
||||
const snapshot = new Map<string, string | undefined>();
|
||||
for (const key of keys) {
|
||||
snapshot.set(key, process.env[key]);
|
||||
}
|
||||
|
||||
return {
|
||||
restore() {
|
||||
for (const [key, value] of snapshot) {
|
||||
if (value === undefined) {
|
||||
delete process.env[key];
|
||||
} else {
|
||||
process.env[key] = value;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user