diff --git a/packages/cli/src/__tests__/agent-setup-cov.test.ts b/packages/cli/src/__tests__/agent-setup-cov.test.ts index 26c9add3..892cac38 100644 --- a/packages/cli/src/__tests__/agent-setup-cov.test.ts +++ b/packages/cli/src/__tests__/agent-setup-cov.test.ts @@ -2,8 +2,9 @@ * agent-setup-cov.test.ts — Coverage tests for shared/agent-setup.ts * * Covers: createCloudAgents, offerGithubAuth, installAgent, - * uploadConfigFile, validateRemotePath, setupAutoUpdate + * uploadConfigFile, validateRemotePath * (wrapSshCall is covered in with-retry-result.test.ts) + * (setupAutoUpdate is covered in auto-update.test.ts) */ import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from "bun:test"; @@ -15,7 +16,7 @@ const clackMocks = mockClackPrompts({ }); // Must import after mock.module for @clack/prompts -const { offerGithubAuth, createCloudAgents, setupAutoUpdate } = await import("../shared/agent-setup.js"); +const { offerGithubAuth, createCloudAgents } = await import("../shared/agent-setup.js"); let stderrSpy: ReturnType; @@ -84,34 +85,6 @@ describe("offerGithubAuth", () => { }); }); -// ── setupAutoUpdate ──────────────────────────────────────────────────── - -describe("setupAutoUpdate", () => { - it("runs update setup commands on the remote", async () => { - const runner = { - runServer: mock(() => Promise.resolve()), - uploadFile: mock(() => Promise.resolve()), - downloadFile: mock(() => Promise.resolve()), - }; - await setupAutoUpdate(runner, "claude", "npm update -g @anthropic-ai/claude-code"); - expect(runner.runServer).toHaveBeenCalled(); - // Should have been called with a command containing the update cmd - const calls = runner.runServer.mock.calls; - const allCmds = calls.map((c: unknown[]) => String(c[0])).join(" "); - expect(allCmds).toContain("systemd"); - }); - - it("handles failure gracefully", async () => { - const runner = { - runServer: mock(() => Promise.reject(new Error("failed"))), - uploadFile: mock(() => Promise.resolve()), - downloadFile: mock(() => Promise.resolve()), - }; - // Should not throw - await setupAutoUpdate(runner, "agent", "update-cmd"); - }); -}); - // ── createCloudAgents ────────────────────────────────────────────────── describe("createCloudAgents", () => { diff --git a/packages/cli/src/__tests__/do-cov.test.ts b/packages/cli/src/__tests__/do-cov.test.ts index dfea3146..85a55ac7 100644 --- a/packages/cli/src/__tests__/do-cov.test.ts +++ b/packages/cli/src/__tests__/do-cov.test.ts @@ -357,64 +357,6 @@ describe("digitalocean/listServers", () => { }); }); -// ─── findSpawnSnapshot ─────────────────────────────────────────────────────── - -describe("digitalocean/findSpawnSnapshot", () => { - it("returns null when no snapshots found", async () => { - global.fetch = mock(() => - Promise.resolve( - new Response( - JSON.stringify({ - images: [], - }), - ), - ), - ); - const { findSpawnSnapshot } = await import("../digitalocean/digitalocean"); - const result = await findSpawnSnapshot("claude"); - expect(result).toBeNull(); - }); - - it("returns latest snapshot ID", async () => { - const resp = { - images: [ - { - id: 100, - name: "spawn-claude-v1", - created_at: "2025-01-01T00:00:00Z", - }, - { - id: 200, - name: "spawn-claude-v2", - created_at: "2025-06-01T00:00:00Z", - }, - { - id: 300, - name: "spawn-other-v1", - created_at: "2025-12-01T00:00:00Z", - }, - ], - }; - global.fetch = mock(() => Promise.resolve(new Response(JSON.stringify(resp)))); - const { findSpawnSnapshot } = await import("../digitalocean/digitalocean"); - const result = await findSpawnSnapshot("claude"); - expect(result).toBe("200"); - }); - - it("returns null on API error", async () => { - global.fetch = mock(() => - Promise.resolve( - new Response("error", { - status: 500, - }), - ), - ); - const { findSpawnSnapshot } = await import("../digitalocean/digitalocean"); - const result = await findSpawnSnapshot("claude"); - expect(result).toBeNull(); - }); -}); - // ─── promptSwitchAccount ───────────────────────────────────────────────────── describe("digitalocean/promptSwitchAccount", () => {