mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 23:56:07 +00:00
test: tighten ssh config spawn assertions
This commit is contained in:
@@ -46,6 +46,15 @@ vi.mock("node:child_process", async () => {
|
||||
|
||||
const spawnMock = vi.mocked(spawn);
|
||||
|
||||
function requireSpawnArgs(index: number): string[] {
|
||||
const args = spawnMock.mock.calls[index]?.[1] as string[] | undefined;
|
||||
expect(args).toBeDefined();
|
||||
if (!args) {
|
||||
throw new Error("expected ssh spawn args");
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
let parseSshConfigOutput: typeof import("./ssh-config.js").parseSshConfigOutput;
|
||||
let resolveSshConfig: typeof import("./ssh-config.js").resolveSshConfig;
|
||||
|
||||
@@ -81,8 +90,7 @@ describe("ssh-config", () => {
|
||||
expect(config?.host).toBe("peters-mac-studio-1.sheep-coho.ts.net");
|
||||
expect(config?.port).toBe(2222);
|
||||
expect(config?.identityFiles).toEqual(["/tmp/id_ed25519"]);
|
||||
const args = spawnMock.mock.calls[0]?.[1] as string[] | undefined;
|
||||
expect(args?.slice(-2)).toEqual(["--", "me@alias"]);
|
||||
expect(requireSpawnArgs(0).slice(-2)).toEqual(["--", "me@alias"]);
|
||||
});
|
||||
|
||||
it("adds non-default port and trimmed identity arguments", async () => {
|
||||
|
||||
Reference in New Issue
Block a user