-
-
Notifications
You must be signed in to change notification settings - Fork 258
Expand file tree
/
Copy pathpostgis-container.test.ts
More file actions
45 lines (36 loc) · 1.25 KB
/
postgis-container.test.ts
File metadata and controls
45 lines (36 loc) · 1.25 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
import { Client } from "pg";
import { PostgreSqlContainer } from "./postgresql-container";
const IMAGE = "postgis/postgis:16-3.4";
describe("PostgisContainer", { timeout: 180_000 }, () => {
it("should work", async () => {
const 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();
await container.stop();
});
it("should restart", async () => {
const 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();
await container.stop();
});
});