Skip to content

Commit 99b41b5

Browse files
committed
updates sql test to not use befdoreAll
1 parent c5feb10 commit 99b41b5

File tree

1 file changed

+49
-51
lines changed

1 file changed

+49
-51
lines changed

test/js/sql/sql.test.ts

Lines changed: 49 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { $, randomUUIDv7, sql, SQL } from "bun";
2-
import { afterAll, beforeAll, describe, expect, mock, test } from "bun:test";
2+
import { afterAll, describe, expect, mock, test } from "bun:test";
33
import { bunEnv, bunExe, isCI, isDockerEnabled, tempDirWithFiles } from "harness";
44
import * as net from "node:net";
55
import path from "path";
@@ -18,7 +18,7 @@ import * as dockerCompose from "../../docker/index.ts";
1818
import { UnixDomainSocketProxy } from "../../unix-domain-socket-proxy.ts";
1919

2020
if (isDockerEnabled()) {
21-
describe("PostgreSQL tests", () => {
21+
describe("PostgreSQL tests", async () => {
2222
let container: { port: number; host: string };
2323
let socketProxy: UnixDomainSocketProxy;
2424
let login: Bun.SQL.PostgresOrMySQLOptions;
@@ -27,55 +27,53 @@ if (isDockerEnabled()) {
2727
let login_scram: Bun.SQL.PostgresOrMySQLOptions;
2828
let options: Bun.SQL.PostgresOrMySQLOptions;
2929

30-
beforeAll(async () => {
31-
const info = await dockerCompose.ensure("postgres_plain");
32-
console.log("PostgreSQL container ready at:", info.host + ":" + info.ports[5432]);
33-
container = {
34-
port: info.ports[5432],
35-
host: info.host,
36-
};
37-
process.env.DATABASE_URL = `postgres://bun_sql_test@${container.host}:${container.port}/bun_sql_test`;
38-
39-
// Create Unix socket proxy for PostgreSQL
40-
socketProxy = await UnixDomainSocketProxy.create("PostgreSQL", container.host, container.port);
41-
42-
login = {
43-
username: "bun_sql_test",
44-
host: container.host,
45-
port: container.port,
46-
path: socketProxy.path,
47-
};
48-
49-
login_domain_socket = {
50-
username: "bun_sql_test",
51-
host: container.host,
52-
port: container.port,
53-
path: socketProxy.path,
54-
};
55-
56-
login_md5 = {
57-
username: "bun_sql_test_md5",
58-
password: "bun_sql_test_md5",
59-
host: container.host,
60-
port: container.port,
61-
};
62-
63-
login_scram = {
64-
username: "bun_sql_test_scram",
65-
password: "bun_sql_test_scram",
66-
host: container.host,
67-
port: container.port,
68-
};
69-
70-
options = {
71-
db: "bun_sql_test",
72-
username: login.username,
73-
password: login.password,
74-
host: container.host,
75-
port: container.port,
76-
max: 1,
77-
};
78-
});
30+
const info = await dockerCompose.ensure("postgres_plain");
31+
console.log("PostgreSQL container ready at:", info.host + ":" + info.ports[5432]);
32+
container = {
33+
port: info.ports[5432],
34+
host: info.host,
35+
};
36+
process.env.DATABASE_URL = `postgres://bun_sql_test@${container.host}:${container.port}/bun_sql_test`;
37+
38+
// Create Unix socket proxy for PostgreSQL
39+
socketProxy = await UnixDomainSocketProxy.create("PostgreSQL", container.host, container.port);
40+
41+
login = {
42+
username: "bun_sql_test",
43+
host: container.host,
44+
port: container.port,
45+
path: socketProxy.path,
46+
};
47+
48+
login_domain_socket = {
49+
username: "bun_sql_test",
50+
host: container.host,
51+
port: container.port,
52+
path: socketProxy.path,
53+
};
54+
55+
login_md5 = {
56+
username: "bun_sql_test_md5",
57+
password: "bun_sql_test_md5",
58+
host: container.host,
59+
port: container.port,
60+
};
61+
62+
login_scram = {
63+
username: "bun_sql_test_scram",
64+
password: "bun_sql_test_scram",
65+
host: container.host,
66+
port: container.port,
67+
};
68+
69+
options = {
70+
db: "bun_sql_test",
71+
username: login.username,
72+
password: login.password,
73+
host: container.host,
74+
port: container.port,
75+
max: 1,
76+
};
7977

8078
afterAll(async () => {
8179
// Containers persist - managed by docker-compose

0 commit comments

Comments
 (0)