diff options
author | 2023-10-05 15:12:07 -0800 | |
---|---|---|
committer | 2023-10-05 16:12:07 -0700 | |
commit | 5c37d5293c90b6cdb737bf1a4c1eeb4ff62c805e (patch) | |
tree | c8524171696ed07ac6ee34b8250038df23d12c69 | |
parent | 323ae0f2a3977327da55273733f947985eea9b8f (diff) | |
download | bun-5c37d5293c90b6cdb737bf1a4c1eeb4ff62c805e.tar.gz bun-5c37d5293c90b6cdb737bf1a4c1eeb4ff62c805e.tar.zst bun-5c37d5293c90b6cdb737bf1a4c1eeb4ff62c805e.zip |
test(bun install): cover http(s) non-github case (#6190)
-rw-r--r-- | test/cli/install/bun-install.test.ts | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/cli/install/bun-install.test.ts b/test/cli/install/bun-install.test.ts index 6b0d313f9..22c7f5b88 100644 --- a/test/cli/install/bun-install.test.ts +++ b/test/cli/install/bun-install.test.ts @@ -3172,6 +3172,54 @@ it("should handle GitHub tarball URL in dependencies (https://github.com/user/re await access(join(package_dir, "bun.lockb")); }); +it("should treat non-GitHub http(s) URLs as tarballs (https://some.url/path?stuff)", async () => { + const urls: string[] = []; + setHandler(dummyRegistry(urls)); + await writeFile( + join(package_dir, "package.json"), + JSON.stringify({ + name: "Foo", + version: "0.0.1", + dependencies: { + "@vercel/turbopack-node": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230922.2" + }, + }), + ); + const { stdout, stderr, exited } = spawn({ + cmd: [bunExe(), "install"], + cwd: package_dir, + stdout: null, + stdin: "pipe", + stderr: "pipe", + env, + }); + expect(stderr).toBeDefined(); + const err = await new Response(stderr).text(); + expect(err).toContain("Saved lockfile"); + expect(stdout).toBeDefined(); + let out = await new Response(stdout).text(); + out = out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, ""); + out = out.replace(/(github:[^#]+)#[a-f0-9]+/, "$1"); + expect(out.split(/\r?\n/)).toEqual([ + " + @vercel/turbopack-node@https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-node/js?turbopack-230922.2", + "", + " 1 packages installed", + ]); + expect(await exited).toBe(0); + expect(urls.sort()).toBeEmpty(); + expect(requested).toBe(0); + expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([".cache", "@vercel", "loader-runner"]); + expect(await readdirSorted(join(package_dir, "node_modules", "@vercel"))).toEqual(["turbopack-node"]); + expect(await readdirSorted(join(package_dir, "node_modules", "@vercel", "turbopack-node"))).toEqual([ + "package.json", + "src", + "tsconfig.json", + ]); + const package_json = await file(join(package_dir, "node_modules", "when", "package.json")).json(); + expect(package_json.name).toBe("when"); + await access(join(package_dir, "bun.lockb")); +}); + it("should handle GitHub URL with existing lockfile", async () => { const urls: string[] = []; setHandler(dummyRegistry(urls)); |