diff options
author | 2022-12-26 07:20:35 +0200 | |
---|---|---|
committer | 2022-12-25 21:20:35 -0800 | |
commit | 74251fbf5e011191721c96ea520f29a7cc4ea94a (patch) | |
tree | 600e52c4dce92afca5bb9befe00ca6f6d0f20fbc /test/bun.js | |
parent | 08a738c6c8841dcb1b84933b483396d66d702f87 (diff) | |
download | bun-74251fbf5e011191721c96ea520f29a7cc4ea94a.tar.gz bun-74251fbf5e011191721c96ea520f29a7cc4ea94a.tar.zst bun-74251fbf5e011191721c96ea520f29a7cc4ea94a.zip |
[install] use default URL when only auth token is specified (#1664)
Previously it would default to `http://localhost/` which was inconsistent with the case sans token.
Use official `npm` registry as fallback in both cases.
Diffstat (limited to 'test/bun.js')
-rw-r--r-- | test/bun.js/bun-install.test.ts | 38 | ||||
-rw-r--r-- | test/bun.js/bun-install.toml | 2 |
2 files changed, 40 insertions, 0 deletions
diff --git a/test/bun.js/bun-install.test.ts b/test/bun.js/bun-install.test.ts new file mode 100644 index 000000000..1bc4655eb --- /dev/null +++ b/test/bun.js/bun-install.test.ts @@ -0,0 +1,38 @@ +import { spawn, spawnSync } from "bun"; +import { describe, expect, it, test } from "bun:test"; +import { bunExe } from "bunExe"; + +test("bun install", async () => { + const urls = []; + const server = Bun.serve({ + async fetch(request) { + try { + expect(request.method).toBe("GET"); + expect(request.headers.get("accept")).toBe("application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"); + expect(await request.text()).toBe(""); + urls.push(request.url); + return new Response("bar", { status: 404 }); + } finally { + server.stop(); + } + }, + port: 54321, + }); + const { stdout, stderr, exited } = spawn({ + cmd: [bunExe(), "install", "foo", "--config", import.meta.dir + "/bun-install.toml"], + stdout: null, + stdin: "pipe", + stderr: "pipe", + env: { + ...process.env, + BUN_DEBUG_QUIET_LOGS: "1", + }, + }); + expect(stdout).toBeDefined(); + expect(stderr).toBeDefined(); + expect(await new Response(stdout).text()).toBe(""); + var err = await new Response(stderr).text(); + expect(err.split(/\n/)).toContain('error: package "foo" not found localhost/foo 404'); + expect(urls).toContain("http://localhost:54321/foo"); + expect(await exited).toBe(1); +}); diff --git a/test/bun.js/bun-install.toml b/test/bun.js/bun-install.toml new file mode 100644 index 000000000..112c61f86 --- /dev/null +++ b/test/bun.js/bun-install.toml @@ -0,0 +1,2 @@ +[install] +registry = "http://localhost:54321/" |