Skip to content

Commit 568e40e

Browse files
NathanFlurryclaude
andcommitted
feat: US-003 - Create pg-connect fixture
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 97ead62 commit 568e40e

3 files changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"entry": "src/index.js",
3+
"expectation": "fail",
4+
"services": ["postgres"],
5+
"fail": {
6+
"code": 1,
7+
"stderrIncludes": "net.Socket is not supported in sandbox"
8+
}
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "e2e-docker-pg-connect",
3+
"private": true,
4+
"type": "commonjs",
5+
"dependencies": {
6+
"pg": "8.13.1"
7+
}
8+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const { Client } = require("pg");
2+
3+
async function main() {
4+
const client = new Client({
5+
host: process.env.PG_HOST,
6+
port: Number(process.env.PG_PORT),
7+
user: "testuser",
8+
password: "testpass",
9+
database: "testdb",
10+
});
11+
12+
await client.connect();
13+
14+
await client.query(
15+
"CREATE TABLE IF NOT EXISTS test_e2e (id SERIAL PRIMARY KEY, value TEXT)",
16+
);
17+
await client.query("INSERT INTO test_e2e (value) VALUES ($1)", [
18+
"hello-sandbox",
19+
]);
20+
const res = await client.query(
21+
"SELECT value FROM test_e2e WHERE value = $1",
22+
["hello-sandbox"],
23+
);
24+
await client.query("DROP TABLE test_e2e");
25+
await client.end();
26+
27+
console.log(
28+
JSON.stringify({
29+
connected: true,
30+
rowCount: res.rowCount,
31+
value: res.rows[0].value,
32+
}),
33+
);
34+
}
35+
36+
main().catch((err) => {
37+
console.error(err.message);
38+
process.exit(1);
39+
});

0 commit comments

Comments
 (0)