From 2623d652d50f11ee9c033f969aae3f6ff2472d02 Mon Sep 17 00:00:00 2001 From: minhn4 Date: Tue, 14 Jul 2026 18:51:31 +0700 Subject: [PATCH] test(opencode): update curl-upgrade tests for the refuse behavior Commit #82 made a curl-detected binary refuse `codev upgrade` instead of piping upstream's install script, but left two installation tests asserting the old pipe-into-shell path (sanitized script errors, sh fallback). Replace them with one test that asserts the curl method refuses with the reinstall-via-npm message and never runs bash/sh/curl. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../test/installation/installation.test.ts | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/packages/opencode/test/installation/installation.test.ts b/packages/opencode/test/installation/installation.test.ts index dc7bc6376b..9505df2ceb 100644 --- a/packages/opencode/test/installation/installation.test.ts +++ b/packages/opencode/test/installation/installation.test.ts @@ -203,37 +203,22 @@ describe("installation", () => { testEffect( testLayer( - () => new Response("install script with token=secret", { status: 200 }), - (cmd, args) => { - if (cmd === "bash" && args[0] === "--version") return "GNU bash" - if (cmd === "bash" || cmd === "sh") return { code: 1, stderr: "script output with token=secret" } + () => new Response("install script", { status: 200 }), + (cmd) => { + if (cmd === "bash" || cmd === "sh" || cmd === "curl") { + throw new Error("must not run the upstream curl install script") + } return "" }, ), - ).effect("returns sanitized typed errors when the curl install script fails", () => + ).effect("refuses a curl upgrade instead of piping the upstream install script", () => Effect.gen(function* () { const error = yield* Effect.flip(Installation.use.upgrade("curl", "9.9.9")) expect(error).toBeInstanceOf(Installation.UpgradeFailedError) - expect(error.stderr).toBe("Upgrade failed for curl (exit code 1).") + expect(error.stderr).toBe( + "codev was not installed via a supported channel. Reinstall with: npm i -g codev-code", + ) expect(error.message).toBe(error.stderr) - expect(error.stderr).not.toContain("secret") - expect(error.stderr).not.toContain("script output") - }), - ) - - testEffect( - testLayer( - () => new Response("install script", { status: 200 }), - (cmd, args) => { - if (cmd === "bash" && args[0] === "--version") return { code: 1, stderr: "missing" } - if (cmd === "bash") return { code: 1, stderr: "should not execute installer with bash" } - if (cmd === "sh") return "ok" - return "" - }, - ), - ).effect("falls back to sh when bash is unavailable during curl upgrade", () => - Effect.gen(function* () { - yield* Installation.use.upgrade("curl", "9.9.9") }), ) })