-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(node): Add
pg-native
integration tests (#15206)
Co-authored-by: Abhijeet Prasad <[email protected]>
- Loading branch information
1 parent
9789f32
commit e01a428
Showing
5 changed files
with
208 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
dev-packages/node-integration-tests/suites/tracing/postgres/scenario-native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const { loggingTransport } = require('@sentry-internal/node-integration-tests'); | ||
const Sentry = require('@sentry/node'); | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
release: '1.0', | ||
tracesSampleRate: 1.0, | ||
transport: loggingTransport, | ||
}); | ||
|
||
// Stop the process from exiting before the transaction is sent | ||
setInterval(() => {}, 1000); | ||
|
||
const { native } = require('pg'); | ||
const { Client } = native; | ||
|
||
const client = new Client({ port: 5444, user: 'test', password: 'test', database: 'tests' }); | ||
|
||
async function run() { | ||
await Sentry.startSpan( | ||
{ | ||
name: 'Test Transaction', | ||
op: 'transaction', | ||
}, | ||
async () => { | ||
try { | ||
await client.connect(); | ||
|
||
await client | ||
.query( | ||
'CREATE TABLE "NativeUser" ("id" SERIAL NOT NULL,"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,"email" TEXT NOT NULL,"name" TEXT,CONSTRAINT "User_pkey" PRIMARY KEY ("id"));', | ||
) | ||
.catch(() => { | ||
// if this is not a fresh database, the table might already exist | ||
}); | ||
|
||
await client.query('INSERT INTO "NativeUser" ("email", "name") VALUES ($1, $2)', ['tim', '[email protected]']); | ||
await client.query('SELECT * FROM "NativeUser"'); | ||
} finally { | ||
await client.end(); | ||
} | ||
}, | ||
); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.