Skip to content

Commit b08cb2c

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

3 files changed

Lines changed: 54 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": ["mysql"],
5+
"fail": {
6+
"code": 1,
7+
"stderrIncludes": "net.connect 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-mysql2-connect",
3+
"private": true,
4+
"type": "commonjs",
5+
"dependencies": {
6+
"mysql2": "3.11.5"
7+
}
8+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const mysql = require("mysql2/promise");
2+
3+
async function main() {
4+
const conn = await mysql.createConnection({
5+
host: process.env.MYSQL_HOST,
6+
port: Number(process.env.MYSQL_PORT),
7+
user: "testuser",
8+
password: "testpass",
9+
database: "testdb",
10+
});
11+
12+
await conn.execute(
13+
"CREATE TABLE IF NOT EXISTS test_e2e (id INT AUTO_INCREMENT PRIMARY KEY, value VARCHAR(255))",
14+
);
15+
await conn.execute("INSERT INTO test_e2e (value) VALUES (?)", [
16+
"hello-sandbox",
17+
]);
18+
const [rows] = await conn.execute(
19+
"SELECT value FROM test_e2e WHERE value = ?",
20+
["hello-sandbox"],
21+
);
22+
await conn.execute("DROP TABLE test_e2e");
23+
await conn.end();
24+
25+
console.log(
26+
JSON.stringify({
27+
connected: true,
28+
rowCount: rows.length,
29+
value: rows[0].value,
30+
}),
31+
);
32+
}
33+
34+
main().catch((err) => {
35+
console.error(err.message);
36+
process.exit(1);
37+
});

0 commit comments

Comments
 (0)