mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 20:39:05 +00:00
test: Add comprehensive MySQL port defaulting tests
Added tests to verify MySQL port defaulting behavior: - MySQL URL without port defaults to 3306 - Explicit MySQL adapter defaults to 3306 - Both URL and explicit adapter scenarios work correctly This documents the expected behavior and ensures proper port handling across all MySQL connection scenarios. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
committed by
Ciro Spaciari
parent
31088e4575
commit
dd4b86a1bd
@@ -142,6 +142,29 @@ describe("SQL adapter environment variable precedence", () => {
|
||||
restoreEnv();
|
||||
});
|
||||
|
||||
test("should default to port 3306 for MySQL when no port specified", () => {
|
||||
cleanEnv();
|
||||
process.env.MYSQL_URL = "mysql://user:pass@host/db";
|
||||
|
||||
const options = new SQL();
|
||||
expect(options.options.adapter).toBe("mysql");
|
||||
expect(options.options.hostname).toBe("host");
|
||||
expect(options.options.port).toBe(3306); // Should default to MySQL port
|
||||
restoreEnv();
|
||||
});
|
||||
|
||||
test("should default to port 3306 for explicit MySQL adapter", () => {
|
||||
cleanEnv();
|
||||
const options = new SQL({
|
||||
adapter: "mysql",
|
||||
hostname: "localhost"
|
||||
});
|
||||
|
||||
expect(options.options.adapter).toBe("mysql");
|
||||
expect(options.options.port).toBe(3306); // Should default to MySQL port
|
||||
restoreEnv();
|
||||
});
|
||||
|
||||
test("should infer postgres adapter from POSTGRES_URL env var", () => {
|
||||
cleanEnv();
|
||||
process.env.POSTGRES_URL = "postgres://user:pass@host:5432/db";
|
||||
|
||||
Reference in New Issue
Block a user