Refactor runtime around isolated bot instances
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
|
||||
function runCli(args: string[]) {
|
||||
return spawnSync(process.execPath, ["--import", "tsx", path.resolve("src/cli.ts"), ...args], {
|
||||
cwd: path.resolve("."),
|
||||
encoding: "utf8",
|
||||
env: { ...process.env, GORI_GATEWAY_CONFIG: "" }
|
||||
});
|
||||
}
|
||||
|
||||
test("CLI rejects unknown flags and command-specific extra arguments", () => {
|
||||
const unknown = runCli(["status", "--bogus"]);
|
||||
assert.equal(unknown.status, 1);
|
||||
assert.match(unknown.stderr, /Unknown option: --bogus/);
|
||||
|
||||
const extra = runCli(["doctor", "extra"]);
|
||||
assert.equal(extra.status, 1);
|
||||
assert.match(extra.stderr, /doctor accepts only --config/);
|
||||
|
||||
const instanceFlag = runCli(["instance", "list", "--config", "config.json"]);
|
||||
assert.equal(instanceFlag.status, 1);
|
||||
assert.match(instanceFlag.stderr, /instance commands do not accept/);
|
||||
});
|
||||
Reference in New Issue
Block a user