mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
test: reuse discovery env snapshot
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// wide-area DNS records, Bonjour naming, and shutdown cleanup.
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import type { PluginGatewayDiscoveryServiceRegistration } from "../plugins/registry-types.js";
|
||||
import { captureFullEnv } from "../test-utils/env.js";
|
||||
|
||||
type WriteWideAreaGatewayZone = typeof import("../infra/widearea-dns.js").writeWideAreaGatewayZone;
|
||||
type ResolveWideAreaDiscoveryDomain =
|
||||
@@ -118,19 +119,11 @@ function startStuckDiscovery(timeoutMs: string) {
|
||||
}
|
||||
|
||||
describe("startGatewayDiscovery", () => {
|
||||
const prevEnv = { ...process.env };
|
||||
const envSnapshot = captureFullEnv();
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
for (const key of Object.keys(process.env)) {
|
||||
if (!(key in prevEnv)) {
|
||||
delete process.env[key];
|
||||
}
|
||||
}
|
||||
for (const [key, value] of Object.entries(prevEnv)) {
|
||||
process.env[key] = value;
|
||||
}
|
||||
|
||||
envSnapshot.restore();
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user