-
-
Notifications
You must be signed in to change notification settings - Fork 260
Expand file tree
/
Copy pathpgvector-container.test.ts
More file actions
68 lines (55 loc) · 2.08 KB
/
pgvector-container.test.ts
File metadata and controls
68 lines (55 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import path from "node:path";
import { Client } from "pg";
import { getImage } from "../../../testcontainers/src/utils/test-helper";
import { PostgreSqlContainer } from "./postgresql-container";
const IMAGE = getImage(__dirname);
const SSL_SERVER_CERT = path.resolve(__dirname, "test-certs/server.crt");
const SSL_SERVER_KEY = path.resolve(__dirname, "test-certs/server.key");
describe("PgvectorContainer", { timeout: 180_000 }, () => {
it("should work", async () => {
await using container = await new PostgreSqlContainer(IMAGE).start();
const client = new Client({
host: container.getHost(),
port: container.getPort(),
database: container.getDatabase(),
user: container.getUsername(),
password: container.getPassword(),
});
await client.connect();
const result = await client.query("SELECT 1");
expect(result.rows[0]).toEqual({ "?column?": 1 });
await client.end();
});
it("should restart", async () => {
await using container = await new PostgreSqlContainer(IMAGE).start();
await container.restart();
const client = new Client({
host: container.getHost(),
port: container.getPort(),
database: container.getDatabase(),
user: container.getUsername(),
password: container.getPassword(),
});
await client.connect();
const result = await client.query("SELECT 1");
expect(result.rows[0]).toEqual({ "?column?": 1 });
await client.end();
});
it("should connect with SSL", async () => {
await using container = await new PostgreSqlContainer(IMAGE).withSSL(SSL_SERVER_CERT, SSL_SERVER_KEY).start();
const client = new Client({
host: container.getHost(),
port: container.getPort(),
database: container.getDatabase(),
user: container.getUsername(),
password: container.getPassword(),
ssl: {
rejectUnauthorized: false,
},
});
await client.connect();
const result = await client.query("SELECT ssl FROM pg_stat_ssl WHERE pid = pg_backend_pid()");
expect(result.rows[0]).toEqual({ ssl: true });
await client.end();
});
});