mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:29:34 +00:00
perf(test): consolidate daemon test entrypoints
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveGatewayStateDir } from "./paths.js";
|
||||
import {
|
||||
buildMinimalServicePath,
|
||||
buildNodeServiceEnvironment,
|
||||
@@ -254,3 +255,35 @@ describe("buildNodeServiceEnvironment", () => {
|
||||
expect(env.HOME).toBe("/home/user");
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveGatewayStateDir", () => {
|
||||
it("uses the default state dir when no overrides are set", () => {
|
||||
const env = { HOME: "/Users/test" };
|
||||
expect(resolveGatewayStateDir(env)).toBe(path.join("/Users/test", ".openclaw"));
|
||||
});
|
||||
|
||||
it("appends the profile suffix when set", () => {
|
||||
const env = { HOME: "/Users/test", OPENCLAW_PROFILE: "rescue" };
|
||||
expect(resolveGatewayStateDir(env)).toBe(path.join("/Users/test", ".openclaw-rescue"));
|
||||
});
|
||||
|
||||
it("treats default profiles as the base state dir", () => {
|
||||
const env = { HOME: "/Users/test", OPENCLAW_PROFILE: "Default" };
|
||||
expect(resolveGatewayStateDir(env)).toBe(path.join("/Users/test", ".openclaw"));
|
||||
});
|
||||
|
||||
it("uses OPENCLAW_STATE_DIR when provided", () => {
|
||||
const env = { HOME: "/Users/test", OPENCLAW_STATE_DIR: "/var/lib/openclaw" };
|
||||
expect(resolveGatewayStateDir(env)).toBe(path.resolve("/var/lib/openclaw"));
|
||||
});
|
||||
|
||||
it("expands ~ in OPENCLAW_STATE_DIR", () => {
|
||||
const env = { HOME: "/Users/test", OPENCLAW_STATE_DIR: "~/openclaw-state" };
|
||||
expect(resolveGatewayStateDir(env)).toBe(path.resolve("/Users/test/openclaw-state"));
|
||||
});
|
||||
|
||||
it("preserves Windows absolute paths without HOME", () => {
|
||||
const env = { OPENCLAW_STATE_DIR: "C:\\State\\openclaw" };
|
||||
expect(resolveGatewayStateDir(env)).toBe("C:\\State\\openclaw");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user