Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
98 lines
3.1 KiB
JavaScript
98 lines
3.1 KiB
JavaScript
"use strict";
|
|
|
|
const assert = require("node:assert/strict");
|
|
const test = require("node:test");
|
|
|
|
const { startDevelopmentPluginHost } = require("./hostBootstrap.cjs");
|
|
|
|
test("disabled development host does not construct plugin infrastructure", () => {
|
|
let created = 0;
|
|
const service = startDevelopmentPluginHost({
|
|
env: {},
|
|
createService() { created += 1; },
|
|
registerShutdown() {},
|
|
logger: { error() {} },
|
|
});
|
|
assert.equal(service, null);
|
|
assert.equal(created, 0);
|
|
});
|
|
|
|
test("synchronous plugin host construction failure leaves Netcatty available", () => {
|
|
const errors = [];
|
|
let registered = 0;
|
|
const service = startDevelopmentPluginHost({
|
|
env: { NETCATTY_PLUGIN_DEV: "1" },
|
|
createService() { throw new Error("corrupt plugin database"); },
|
|
registerShutdown() { registered += 1; },
|
|
logger: { error(...args) { errors.push(args); } },
|
|
});
|
|
assert.equal(service, null);
|
|
assert.equal(registered, 0);
|
|
assert.match(errors[0][1].message, /corrupt plugin database/);
|
|
});
|
|
|
|
test("created plugin host initializes and registers one shutdown owner", async () => {
|
|
let initialized = 0;
|
|
let shutdown = 0;
|
|
let shutdownHandler;
|
|
const service = {
|
|
manager: {
|
|
async initialize() { initialized += 1; },
|
|
async shutdown() { shutdown += 1; },
|
|
},
|
|
};
|
|
assert.equal(startDevelopmentPluginHost({
|
|
env: { NETCATTY_PLUGIN_DEV: "1" },
|
|
createService: () => service,
|
|
registerShutdown(handler) { shutdownHandler = handler; },
|
|
logger: { error() {} },
|
|
}), service);
|
|
await new Promise((resolve) => setImmediate(resolve));
|
|
assert.equal(initialized, 1);
|
|
await shutdownHandler();
|
|
assert.equal(shutdown, 1);
|
|
});
|
|
|
|
test("asynchronous initialization failure closes and leaves the host unavailable", async () => {
|
|
let shutdown = 0;
|
|
let shutdownHandler;
|
|
const errors = [];
|
|
const service = {
|
|
manager: {
|
|
initialize: async () => { throw new Error("recovery failed"); },
|
|
shutdown: async () => { shutdown += 1; },
|
|
},
|
|
};
|
|
assert.equal(startDevelopmentPluginHost({
|
|
env: { NETCATTY_PLUGIN_DEV: "1" },
|
|
createService: () => service,
|
|
registerShutdown(handler) { shutdownHandler = handler; },
|
|
logger: { error(...args) { errors.push(args); } },
|
|
}), service);
|
|
await new Promise((resolve) => setImmediate(resolve));
|
|
assert.equal(shutdown, 1);
|
|
assert.match(errors[0][1].message, /recovery failed/);
|
|
await shutdownHandler();
|
|
assert.equal(shutdown, 2);
|
|
});
|
|
|
|
test("failure while registering shutdown closes the constructed host", async () => {
|
|
let shutdown = 0;
|
|
const errors = [];
|
|
const service = startDevelopmentPluginHost({
|
|
env: { NETCATTY_PLUGIN_DEV: "1" },
|
|
createService: () => ({
|
|
manager: {
|
|
async initialize() {},
|
|
async shutdown() { shutdown += 1; },
|
|
},
|
|
}),
|
|
registerShutdown() { throw new Error("shutdown registry unavailable"); },
|
|
logger: { error(...args) { errors.push(args); } },
|
|
});
|
|
assert.equal(service, null);
|
|
await new Promise((resolve) => setImmediate(resolve));
|
|
assert.equal(shutdown, 1);
|
|
assert.match(errors[0][1].message, /shutdown registry unavailable/);
|
|
});
|