mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-28 17:43:05 +00:00
test: consolidate gateway profile normalization coverage
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
GATEWAY_LAUNCH_AGENT_LABEL,
|
||||
GATEWAY_SYSTEMD_SERVICE_NAME,
|
||||
GATEWAY_WINDOWS_TASK_NAME,
|
||||
normalizeGatewayProfile,
|
||||
resolveGatewayLaunchAgentLabel,
|
||||
resolveGatewayProfileSuffix,
|
||||
resolveGatewayServiceDescription,
|
||||
@@ -11,6 +12,21 @@ import {
|
||||
resolveGatewayWindowsTaskName,
|
||||
} from "./constants.js";
|
||||
|
||||
describe("normalizeGatewayProfile", () => {
|
||||
it("returns null for empty/default profiles", () => {
|
||||
expect(normalizeGatewayProfile()).toBeNull();
|
||||
expect(normalizeGatewayProfile("")).toBeNull();
|
||||
expect(normalizeGatewayProfile(" ")).toBeNull();
|
||||
expect(normalizeGatewayProfile("default")).toBeNull();
|
||||
expect(normalizeGatewayProfile(" Default ")).toBeNull();
|
||||
});
|
||||
|
||||
it("returns trimmed custom profiles", () => {
|
||||
expect(normalizeGatewayProfile("dev")).toBe("dev");
|
||||
expect(normalizeGatewayProfile(" staging ")).toBe("staging");
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveGatewayLaunchAgentLabel", () => {
|
||||
it("returns default label when no profile is set", () => {
|
||||
const result = resolveGatewayLaunchAgentLabel();
|
||||
@@ -18,16 +34,6 @@ describe("resolveGatewayLaunchAgentLabel", () => {
|
||||
expect(result).toBe("ai.openclaw.gateway");
|
||||
});
|
||||
|
||||
it("returns default label when profile is 'default'", () => {
|
||||
const result = resolveGatewayLaunchAgentLabel("default");
|
||||
expect(result).toBe(GATEWAY_LAUNCH_AGENT_LABEL);
|
||||
});
|
||||
|
||||
it("returns default label when profile is 'Default' (case-insensitive)", () => {
|
||||
const result = resolveGatewayLaunchAgentLabel("Default");
|
||||
expect(result).toBe(GATEWAY_LAUNCH_AGENT_LABEL);
|
||||
});
|
||||
|
||||
it("returns profile-specific label when profile is set", () => {
|
||||
const result = resolveGatewayLaunchAgentLabel("dev");
|
||||
expect(result).toBe("ai.openclaw.dev");
|
||||
@@ -37,16 +43,6 @@ describe("resolveGatewayLaunchAgentLabel", () => {
|
||||
const result = resolveGatewayLaunchAgentLabel(" staging ");
|
||||
expect(result).toBe("ai.openclaw.staging");
|
||||
});
|
||||
|
||||
it("returns default label for empty string profile", () => {
|
||||
const result = resolveGatewayLaunchAgentLabel("");
|
||||
expect(result).toBe(GATEWAY_LAUNCH_AGENT_LABEL);
|
||||
});
|
||||
|
||||
it("returns default label for whitespace-only profile", () => {
|
||||
const result = resolveGatewayLaunchAgentLabel(" ");
|
||||
expect(result).toBe(GATEWAY_LAUNCH_AGENT_LABEL);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveGatewaySystemdServiceName", () => {
|
||||
@@ -56,11 +52,6 @@ describe("resolveGatewaySystemdServiceName", () => {
|
||||
expect(result).toBe("openclaw-gateway");
|
||||
});
|
||||
|
||||
it("returns default service name when profile is 'default'", () => {
|
||||
const result = resolveGatewaySystemdServiceName("default");
|
||||
expect(result).toBe(GATEWAY_SYSTEMD_SERVICE_NAME);
|
||||
});
|
||||
|
||||
it("returns profile-specific service name when profile is set", () => {
|
||||
const result = resolveGatewaySystemdServiceName("dev");
|
||||
expect(result).toBe("openclaw-gateway-dev");
|
||||
@@ -70,16 +61,6 @@ describe("resolveGatewaySystemdServiceName", () => {
|
||||
const result = resolveGatewaySystemdServiceName(" test ");
|
||||
expect(result).toBe("openclaw-gateway-test");
|
||||
});
|
||||
|
||||
it("returns default service name for empty string profile", () => {
|
||||
const result = resolveGatewaySystemdServiceName("");
|
||||
expect(result).toBe(GATEWAY_SYSTEMD_SERVICE_NAME);
|
||||
});
|
||||
|
||||
it("returns default service name for whitespace-only profile", () => {
|
||||
const result = resolveGatewaySystemdServiceName(" ");
|
||||
expect(result).toBe(GATEWAY_SYSTEMD_SERVICE_NAME);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveGatewayWindowsTaskName", () => {
|
||||
@@ -89,11 +70,6 @@ describe("resolveGatewayWindowsTaskName", () => {
|
||||
expect(result).toBe("OpenClaw Gateway");
|
||||
});
|
||||
|
||||
it("returns default task name when profile is 'default'", () => {
|
||||
const result = resolveGatewayWindowsTaskName("default");
|
||||
expect(result).toBe(GATEWAY_WINDOWS_TASK_NAME);
|
||||
});
|
||||
|
||||
it("returns profile-specific task name when profile is set", () => {
|
||||
const result = resolveGatewayWindowsTaskName("dev");
|
||||
expect(result).toBe("OpenClaw Gateway (dev)");
|
||||
@@ -103,16 +79,6 @@ describe("resolveGatewayWindowsTaskName", () => {
|
||||
const result = resolveGatewayWindowsTaskName(" ci ");
|
||||
expect(result).toBe("OpenClaw Gateway (ci)");
|
||||
});
|
||||
|
||||
it("returns default task name for empty string profile", () => {
|
||||
const result = resolveGatewayWindowsTaskName("");
|
||||
expect(result).toBe(GATEWAY_WINDOWS_TASK_NAME);
|
||||
});
|
||||
|
||||
it("returns default task name for whitespace-only profile", () => {
|
||||
const result = resolveGatewayWindowsTaskName(" ");
|
||||
expect(result).toBe(GATEWAY_WINDOWS_TASK_NAME);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveGatewayProfileSuffix", () => {
|
||||
|
||||
Reference in New Issue
Block a user