mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 14:58:26 +00:00
perf(test): reduce module reload overhead in key suites
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
restoreStateDirEnv,
|
||||
setStateDirEnv,
|
||||
snapshotStateDirEnv,
|
||||
} from "../test-helpers/state-dir-env.js";
|
||||
import { loadOrCreateDeviceIdentity } from "./device-identity.js";
|
||||
|
||||
describe("device identity state dir defaults", () => {
|
||||
let envSnapshot: ReturnType<typeof snapshotStateDirEnv>;
|
||||
@@ -16,7 +17,6 @@ describe("device identity state dir defaults", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.resetModules();
|
||||
restoreStateDirEnv(envSnapshot);
|
||||
});
|
||||
|
||||
@@ -24,9 +24,6 @@ describe("device identity state dir defaults", () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-identity-state-"));
|
||||
const stateDir = path.join(tempRoot, "state");
|
||||
setStateDirEnv(stateDir);
|
||||
vi.resetModules();
|
||||
|
||||
const { loadOrCreateDeviceIdentity } = await import("./device-identity.js");
|
||||
const identity = loadOrCreateDeviceIdentity();
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user