mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-04-28 03:49:31 +00:00
test: remove duplicate and theatrical tests (#2616)
The ensureSshKeys tests had two identical tests covering the same code path: "uses all keys in non-interactive mode when multiple exist" and "uses all keys when multiselect is unavailable". Both created the same two fake key pairs, used the same spawnSync mock, and made the identical assertion (toHaveLength(2)). The first test set SPAWN_NON_INTERACTIVE=1 which ensureSshKeys does not check — stale logic from a removed interactive multiselect flow. The second test referenced unavailable @clack/prompts multiselect which also no longer exists in the implementation. Consolidated into one deterministic test that also validates key ordering (ed25519 sorts before rsa). -- qa/dedup-scanner Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
This commit is contained in:
parent
1195fcb648
commit
6988ac7acf
1 changed files with 3 additions and 19 deletions
|
|
@ -304,25 +304,7 @@ describe("ensureSshKeys", () => {
|
|||
expect(keys[0].name).toBe("id_rsa");
|
||||
});
|
||||
|
||||
it("uses all keys in non-interactive mode when multiple exist", async () => {
|
||||
process.env.SPAWN_NON_INTERACTIVE = "1";
|
||||
createFakeKeyPair("id_ed25519", "ed25519");
|
||||
createFakeKeyPair("id_rsa", "rsa");
|
||||
|
||||
const spawnSpy = spyOn(Bun, "spawnSync").mockImplementation((args: string[]) => {
|
||||
const pubPath = args[args.length - 1];
|
||||
const type = pubPath.includes("ed25519") ? "ED25519" : "RSA";
|
||||
return sshKeygenLfResult(type);
|
||||
});
|
||||
|
||||
const keys = await ensureSshKeys();
|
||||
spawnSpy.mockRestore();
|
||||
expect(keys).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("uses all keys when multiselect is unavailable", async () => {
|
||||
// In test environments, @clack/prompts multiselect may not be available
|
||||
// due to global mock.module ordering — ensureSshKeys falls back to all keys
|
||||
it("uses all discovered keys when multiple exist", async () => {
|
||||
createFakeKeyPair("id_ed25519", "ed25519");
|
||||
createFakeKeyPair("id_rsa", "rsa");
|
||||
|
||||
|
|
@ -335,6 +317,8 @@ describe("ensureSshKeys", () => {
|
|||
const keys = await ensureSshKeys();
|
||||
spawnSpy.mockRestore();
|
||||
expect(keys).toHaveLength(2);
|
||||
expect(keys[0].name).toBe("id_ed25519");
|
||||
expect(keys[1].name).toBe("id_rsa");
|
||||
});
|
||||
|
||||
it("caches results across calls", async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue