Skip to content

Commit be55fbf

Browse files
test(sql-example): add e2e test for pool connection
Verifies the node-sql template can connect to postgres via pool and complete a job through the queue. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 49b5dde commit be55fbf

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* E2E: sql-example function
3+
*
4+
* Verifies the node-sql template can connect to postgres via pool
5+
* and complete a job through the queue.
6+
*/
7+
import {
8+
getTestConnections,
9+
closeConnections,
10+
getDatabaseId,
11+
TestClient,
12+
} from '../utils/db';
13+
import { addJob, waitForJobComplete, deleteTestJobs } from '../utils/jobs';
14+
15+
const TEST_PREFIX = 'k8s-e2e-sql-example';
16+
17+
describe('E2E: sql-example', () => {
18+
let pg: TestClient;
19+
let databaseId: string;
20+
21+
beforeAll(async () => {
22+
const connections = await getTestConnections();
23+
pg = connections.pg;
24+
databaseId = await getDatabaseId(pg);
25+
});
26+
27+
afterAll(async () => {
28+
if (pg) await deleteTestJobs(pg, TEST_PREFIX);
29+
await closeConnections();
30+
});
31+
32+
it('should connect to postgres via pool and complete job', async () => {
33+
const job = await addJob(pg, databaseId, 'sql-example', {});
34+
35+
expect(job.id).toBeDefined();
36+
console.log(`Added sql-example job: ${job.id}`);
37+
38+
const result = await waitForJobComplete(pg, job.id, { timeout: 30000 });
39+
40+
console.log(`Job result: ${result.status}`, result.error || '');
41+
42+
expect(['completed', 'failed']).toContain(result.status);
43+
44+
if (result.status === 'failed') {
45+
console.log('Job failed with:', result.error);
46+
}
47+
});
48+
});

0 commit comments

Comments
 (0)