mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
### What does this PR do? ### How did you verify your code works? --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Claude Bot <claude-bot@bun.sh>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { SQL } from "bun";
|
|
import { expect, test } from "bun:test";
|
|
import { describeWithContainer } from "harness";
|
|
|
|
describeWithContainer(
|
|
"mysql",
|
|
{
|
|
image: "mysql_native_password",
|
|
env: {},
|
|
args: [],
|
|
concurrent: true,
|
|
},
|
|
container => {
|
|
// Create getters that will be evaluated when the test runs
|
|
const getUrl = () => `mysql://root:bun@${container.host}:${container.port}/bun_sql_test`;
|
|
|
|
test("should be able to connect with mysql_native_password auth plugin", async () => {
|
|
console.log("Container info in test:", container);
|
|
await using sql = new SQL({
|
|
url: getUrl(),
|
|
max: 1,
|
|
});
|
|
const result = await sql`select 1 as x`;
|
|
expect(result).toEqual([{ x: 1 }]);
|
|
await sql.end();
|
|
});
|
|
|
|
test("should be able to switch auth plugin", async () => {
|
|
{
|
|
await using sql = new SQL({
|
|
url: getUrl(),
|
|
max: 1,
|
|
});
|
|
|
|
await sql`DROP USER IF EXISTS caching@'%';`.simple();
|
|
await sql`CREATE USER caching@'%' IDENTIFIED WITH caching_sha2_password BY 'bunbun';
|
|
GRANT ALL PRIVILEGES ON bun_sql_test.* TO caching@'%';
|
|
FLUSH PRIVILEGES;`.simple();
|
|
}
|
|
await using sql = new SQL(`mysql://caching:bunbun@${container.host}:${container.port}/bun_sql_test`);
|
|
const result = await sql`select 1 as x`;
|
|
expect(result).toEqual([{ x: 1 }]);
|
|
await sql.end();
|
|
});
|
|
},
|
|
);
|