mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 20:14:30 +00:00
refactor(test): snapshot tailscale test env per case
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
import { captureEnv } from "../test-utils/env.js";
|
||||||
import * as tailscale from "./tailscale.js";
|
import * as tailscale from "./tailscale.js";
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -12,18 +13,15 @@ const {
|
|||||||
const tailscaleBin = expect.stringMatching(/tailscale$/i);
|
const tailscaleBin = expect.stringMatching(/tailscale$/i);
|
||||||
|
|
||||||
describe("tailscale helpers", () => {
|
describe("tailscale helpers", () => {
|
||||||
const originalForcedBinary = process.env.OPENCLAW_TEST_TAILSCALE_BINARY;
|
let envSnapshot: ReturnType<typeof captureEnv>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
envSnapshot = captureEnv(["OPENCLAW_TEST_TAILSCALE_BINARY"]);
|
||||||
process.env.OPENCLAW_TEST_TAILSCALE_BINARY = "tailscale";
|
process.env.OPENCLAW_TEST_TAILSCALE_BINARY = "tailscale";
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
if (originalForcedBinary === undefined) {
|
envSnapshot.restore();
|
||||||
delete process.env.OPENCLAW_TEST_TAILSCALE_BINARY;
|
|
||||||
} else {
|
|
||||||
process.env.OPENCLAW_TEST_TAILSCALE_BINARY = originalForcedBinary;
|
|
||||||
}
|
|
||||||
vi.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user