Skip to content

test(sql): use container.host instead of hardcoded localhost in 'Connect using uri'#31901

Merged
alii merged 1 commit into
mainfrom
claude/sql-test-container-host
Jun 5, 2026
Merged

test(sql): use container.host instead of hardcoded localhost in 'Connect using uri'#31901
alii merged 1 commit into
mainfrom
claude/sql-test-container-host

Conversation

@alii

@alii alii commented Jun 5, 2026

Copy link
Copy Markdown
Member

What

One-line fix in test/js/sql/sql.test.ts: the "Connect using uri" test built its connection string with a hardcoded @localhost: instead of container.host.

Why

Every other test in the file uses container.host (which respects BUN_DOCKER_TEST_HOST, added in #31731), so they pass against any Docker setup — local or remote daemon. This one test only worked when the daemon is on the same machine. Against a remote daemon it fails instantly with PostgresError: Connection closed, and that single subtest marks the whole 845-test file as failed even though the other 844 pass.

How verified

With this change, the full sql.test.ts passes (843 pass / 2 todo / 0 fail) against a remote Docker daemon on macOS arm64, and behavior on a local daemon is unchanged (container.host resolves to 127.0.0.1 there).

…ect using uri'

The compose helper returns the docker host (BUN_DOCKER_TEST_HOST aware) but
this test built its URI with a hardcoded localhost, failing instantly against
any remote docker daemon while every other test in the file passes.
@robobun

robobun commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

@alii alii merged commit 82808d4 into main Jun 5, 2026
7 of 8 checks passed
@alii alii deleted the claude/sql-test-container-host branch June 5, 2026 21:51
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Looking for one thing? Review this PR in Change Stack to search files, summaries, diffs, and code without losing your place.

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 97ab6ff9-380a-4b22-9f76-a2a56f993337

📥 Commits

Reviewing files that changed from the base of the PR and between a1dd647 and b5d8394.

📒 Files selected for processing (1)
  • test/js/sql/sql.test.ts

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


Walkthrough

The PostgreSQL connection test is updated to use a dynamically resolved Docker container host instead of a hardcoded localhost value when constructing the connection URI.

Changes

Docker Container Host Integration

Layer / File(s) Summary
Dynamic container host in PostgreSQL URI test
test/js/sql/sql.test.ts
The "Connect using uri" test now uses container.host instead of the literal "localhost" when constructing the Postgres connection URI, allowing the test to work with dynamically assigned Docker container hosts.

Possibly related PRs

  • oven-sh/bun#31731: Both PRs change how docker-backed tests determine the Postgres connection host by removing hardcoded localhost and routing the selected host through the docker test helper into the constructed connection URI.

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — straightforward test fix aligning with the existing container.host pattern.

Extended reasoning...

Overview

This PR changes a single line in test/js/sql/sql.test.ts, replacing a hardcoded @localhost: in the "Connect using uri" test's connection string with container.host. The file already uses container.host in 8 other places (and container.port is used on the very next line of this same test), so this just brings one straggler in line with the established pattern introduced in #31731.

Security risks

None. This is test-only code constructing a Postgres connection URI for an integration test against a Docker container. No production code, auth, crypto, or permission logic is touched.

Level of scrutiny

Low. It's a one-token mechanical substitution in a test file, matching the convention used everywhere else in the same file. The intent is clear (support remote Docker daemons via BUN_DOCKER_TEST_HOST), and on local setups container.host resolves to 127.0.0.1, so behavior is unchanged there.

Other factors

The PR description includes verification that the full suite now passes against a remote Docker daemon and remains green locally. No bugs were flagged by the bug-hunting pass, and there are no outstanding reviewer comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants