Skip to content

Commit 0a0b08c

Browse files
NathanFlurryclaude
andcommitted
feat: US-021 - Expand pg-connect fixture with UPDATE, DELETE, and transactions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 076ea11 commit 0a0b08c

1 file changed

Lines changed: 55 additions & 3 deletions

File tree

  • packages/secure-exec/tests/e2e-docker/pg-connect/src

packages/secure-exec/tests/e2e-docker/pg-connect/src/index.js

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,76 @@ async function main() {
1111

1212
await client.connect();
1313

14+
// CREATE + INSERT + SELECT (original)
1415
await client.query(
1516
"CREATE TABLE IF NOT EXISTS test_e2e (id SERIAL PRIMARY KEY, value TEXT)",
1617
);
1718
await client.query("INSERT INTO test_e2e (value) VALUES ($1)", [
1819
"hello-sandbox",
1920
]);
20-
const res = await client.query(
21+
const selectRes = await client.query(
2122
"SELECT value FROM test_e2e WHERE value = $1",
2223
["hello-sandbox"],
2324
);
25+
26+
// UPDATE + verify
27+
await client.query("UPDATE test_e2e SET value = $1 WHERE value = $2", [
28+
"updated-sandbox",
29+
"hello-sandbox",
30+
]);
31+
const updateRes = await client.query(
32+
"SELECT value FROM test_e2e WHERE value = $1",
33+
["updated-sandbox"],
34+
);
35+
36+
// DELETE + verify
37+
await client.query("DELETE FROM test_e2e WHERE value = $1", [
38+
"updated-sandbox",
39+
]);
40+
const deleteRes = await client.query(
41+
"SELECT value FROM test_e2e WHERE value = $1",
42+
["updated-sandbox"],
43+
);
44+
45+
// Transaction: ROLLBACK
46+
await client.query("BEGIN");
47+
await client.query("INSERT INTO test_e2e (value) VALUES ($1)", [
48+
"rollback-test",
49+
]);
50+
await client.query("ROLLBACK");
51+
const rollbackRes = await client.query(
52+
"SELECT value FROM test_e2e WHERE value = $1",
53+
["rollback-test"],
54+
);
55+
56+
// Transaction: COMMIT
57+
await client.query("BEGIN");
58+
await client.query("INSERT INTO test_e2e (value) VALUES ($1)", [
59+
"commit-test",
60+
]);
61+
await client.query("COMMIT");
62+
const commitRes = await client.query(
63+
"SELECT value FROM test_e2e WHERE value = $1",
64+
["commit-test"],
65+
);
66+
2467
await client.query("DROP TABLE test_e2e");
2568
await client.end();
2669

2770
console.log(
2871
JSON.stringify({
2972
connected: true,
30-
rowCount: res.rowCount,
31-
value: res.rows[0].value,
73+
insert: { rowCount: selectRes.rowCount, value: selectRes.rows[0].value },
74+
update: {
75+
rowCount: updateRes.rowCount,
76+
value: updateRes.rows[0].value,
77+
},
78+
delete: { rowCount: deleteRes.rowCount },
79+
rollback: { rowCount: rollbackRes.rowCount },
80+
commit: {
81+
rowCount: commitRes.rowCount,
82+
value: commitRes.rows[0].value,
83+
},
3284
}),
3385
);
3486
}

0 commit comments

Comments
 (0)