Files
bun.sh/test/regression/issue/24385.test.ts
Marko Vejnovic 02b474415d bug(ENG-21479): Fix Valkey URL Parsing (#24458)
### What does this PR do?

Fixes https://github.com/oven-sh/bun/issues/24385

### How did you verify your code works?

Confirmed that the test added in the first commit fails on mainline
`bun` and is fixed in this PR.

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2025-11-07 21:18:07 -08:00

38 lines
1.2 KiB
TypeScript

// https://github.com/oven-sh/bun/issues/24385
// Test for Redis client import regression
import { cartesianProduct } from "_util/collection";
import { expect, test } from "bun:test";
import { bunEnv, bunExe } from "harness";
test.concurrent.each(
cartesianProduct(
["REDIS_URL", "VALKEY_URL"],
[
"localhost:6379",
"redis+tls+unix:///tmp/redis.sock",
"redis+tls://localhost:6379",
"redis+unix:///tmp/redis.sock",
"redis://localhost:6379",
"rediss://localhost:6379",
"valkey://localhost:6379",
],
).map(([k, v]) => ({ key: k, value: v })),
)("Redis loads with $key=$value", async ({ key, value }) => {
const env = { ...bunEnv, [key]: value };
await using proc = Bun.spawn({
// We need to call redis.duplicate() since Bun lazily imports redis.
cmd: [bunExe(), "-e", 'import { redis } from "bun"; const d = redis.duplicate(); console.log("success");'],
env,
stderr: "pipe",
stdout: "pipe",
});
const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]);
expect(stderr).not.toContain("Expected url protocol to be one of");
expect(stdout).toContain("success");
expect(exitCode).toBe(0);
});