Files
routstrd/tests/daemon-command.test.ts
hzrd149GitHubhzrd149, redshift <213178690+1ftredsh@users.noreply.github.com>
d3749d4638 feat: add standalone binary releases (#89)
* feat: add standalone binary releases

* fix: propagate async CLI failures

* fix: detect older Bun standalone builds

* fix: constrain npm package contents

* fix: preserve npm daemon entrypoint

* fix: compare prerelease versions correctly

* fix: verify daemon ownership before update restart

* docs: add release and PM2 migration guidance

* ci: validate standalone builds before release

* chore: prepare v0.4.9 release

---------

Co-authored-by: hzrd149, redshift <213178690+1ftredsh@users.noreply.github.com>
2026-09-08 15:23:36 +00:00

39 lines
1.1 KiB
TypeScript

import { afterEach, describe, expect, test } from "bun:test";
import { mkdtempSync, rmSync } from "fs";
import { tmpdir } from "os";
import { join } from "path";
const tempDirs: string[] = [];
function freshConfigPath(): string {
const path = mkdtempSync(join(tmpdir(), "routstrd-daemon-command-test-"));
rmSync(path, { recursive: true });
tempDirs.push(path);
return path;
}
afterEach(() => {
for (const path of tempDirs.splice(0)) {
rmSync(path, { recursive: true, force: true });
}
});
describe("daemon command", () => {
test("reports startup failures on stderr and exits nonzero", async () => {
const entrypoint = join(import.meta.dir, "../src/index.ts");
const proc = Bun.spawn([process.execPath, entrypoint, "daemon", "--port", "9999"], {
env: { ...process.env, ROUTSTRD_DIR: freshConfigPath() },
stdout: "pipe",
stderr: "pipe",
});
const [exitCode, stderr] = await Promise.all([
proc.exited,
new Response(proc.stderr).text(),
]);
expect(exitCode).toBe(1);
expect(stderr).toContain("routstrd command failed:");
});
});