feat(bridge): establish local pi status bridge
Deliver the initial local bridge, Noctalia v4/v5 adapters, desktop client, service unit, tests, and implementation documentation for persistent Pi status and control.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtemp, stat } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import test from "node:test";
|
||||
import { BridgeAlreadyRunningError } from "../src/bridge/instance-lock.js";
|
||||
import {
|
||||
createRuntimePaths,
|
||||
startBridgeServer,
|
||||
} from "../src/bridge/runtime.js";
|
||||
|
||||
test("creates a private runtime directory and enforces one live bridge", async () => {
|
||||
const runtimeDir = await mkdtemp(`${tmpdir()}/pi-status-bridge-runtime-`);
|
||||
const paths = await createRuntimePaths(runtimeDir);
|
||||
const runtimeStats = await stat(paths.directory);
|
||||
assert.equal(runtimeStats.mode & 0o777, 0o700);
|
||||
|
||||
const bridge = await startBridgeServer({
|
||||
runtimeDir,
|
||||
handleRequest: async () => ({}),
|
||||
});
|
||||
try {
|
||||
await assert.rejects(
|
||||
startBridgeServer({ runtimeDir, handleRequest: async () => ({}) }),
|
||||
BridgeAlreadyRunningError,
|
||||
);
|
||||
} finally {
|
||||
await bridge.close();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user