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 { detectMarkerLineWithGateway, findExtraGatewayServices } from "./inspect.js";
// Real content from the openclaw-gateway.service unit file (the canonical gateway unit). const GATEWAY_SERVICE_CONTENTS = `\
[Unit]
Description=OpenClaw Gateway (v2026.3.8)
After=network-online.target
Wants=network-online.target
// Real content from the openclaw-test.service unit file (a non-gateway openclaw service). const TEST_SERVICE_CONTENTS = `\
[Unit]
Description=OpenClaw test service
After=default.target
describe("detectMarkerLineWithGateway", () => {
it("returns null for openclaw-test.service (openclaw only in description, no gateway on same line)", () => {
expect(detectMarkerLineWithGateway(TEST_SERVICE_CONTENTS)).toBeNull();
});
it("returns openclaw for the canonical gateway unit (ExecStart has both openclaw and gateway)", () => {
expect(detectMarkerLineWithGateway(GATEWAY_SERVICE_CONTENTS)).toBe("openclaw");
});
it("returns clawdbot for a clawdbot gateway unit", () => {
expect(detectMarkerLineWithGateway(CLAWDBOT_GATEWAY_CONTENTS)).toBe("clawdbot");
});
it("handles line continuations — marker and gateway split across physical lines", () => { const contents = `[Service]\nExecStart=/usr/bin/node /opt/openclaw/dist/entry.js \\\n gateway --port 18789\n`;
expect(detectMarkerLineWithGateway(contents)).toBe("openclaw");
});
});
describe("findExtraGatewayServices (linux / scanSystemdDir) — real filesystem", () => { // These tests write real .service files to a temp dir and call findExtraGatewayServices // with that dir as HOME. No platform mocking or fs mocking needed. // Only runs on Linux/macOS where the linux branch of findExtraGatewayServices is active. const isLinux = process.platform === "linux";
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.