2026-02-08 05:16:59 +02:00
|
|
|
import fs from "node:fs/promises";
|
|
|
|
|
import path from "node:path";
|
2026-02-21 12:59:14 +00:00
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
|
import { withStateDirEnv } from "../test-helpers/state-dir-env.js";
|
2026-02-13 15:45:08 +00:00
|
|
|
import { loadOrCreateDeviceIdentity } from "./device-identity.js";
|
2026-02-08 05:16:59 +02:00
|
|
|
|
|
|
|
|
describe("device identity state dir defaults", () => {
|
|
|
|
|
it("writes the default identity file under OPENCLAW_STATE_DIR", async () => {
|
2026-02-21 12:59:14 +00:00
|
|
|
await withStateDirEnv("openclaw-identity-state-", async ({ stateDir }) => {
|
|
|
|
|
const identity = loadOrCreateDeviceIdentity();
|
2026-02-08 05:16:59 +02:00
|
|
|
const identityPath = path.join(stateDir, "identity", "device.json");
|
|
|
|
|
const raw = JSON.parse(await fs.readFile(identityPath, "utf8")) as { deviceId?: string };
|
|
|
|
|
expect(raw.deviceId).toBe(identity.deviceId);
|
2026-02-21 12:59:14 +00:00
|
|
|
});
|
2026-02-08 05:16:59 +02:00
|
|
|
});
|
|
|
|
|
});
|