Skip to content

Commit 44e37ea

Browse files
committed
Move tests
1 parent 21840f9 commit 44e37ea

File tree

3 files changed

+27
-74
lines changed

3 files changed

+27
-74
lines changed

plugins/node/opentelemetry-instrumentation-pg/test/fixtures/use-pg.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ const sdk = createTestNodeSdk({
4040
sdk.start();
4141

4242
import pg from 'pg';
43-
4443
const client = new pg.Client(CONFIG);
4544

4645
await client.connect();

plugins/node/opentelemetry-instrumentation-pg/test/pg.esm.test.ts

Lines changed: 0 additions & 73 deletions
This file was deleted.

plugins/node/opentelemetry-instrumentation-pg/test/pg.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,4 +1087,31 @@ describe('pg', () => {
10871087
});
10881088
});
10891089
});
1090+
1091+
it('should work with ESM usage', async () => {
1092+
await testUtils.runTestFixture({
1093+
cwd: __dirname,
1094+
argv: ['fixtures/use-pg.mjs'],
1095+
env: {
1096+
NODE_OPTIONS:
1097+
'--experimental-loader=@opentelemetry/instrumentation/hook.mjs',
1098+
NODE_NO_WARNINGS: '1',
1099+
},
1100+
checkResult: (err, stdout, stderr) => {
1101+
assert.ifError(err);
1102+
},
1103+
checkCollector: (collector: testUtils.TestCollector) => {
1104+
const spans = collector.sortedSpans;
1105+
1106+
assert.strictEqual(spans.length, 3);
1107+
1108+
assert.strictEqual(spans[0].name, 'pg.connect');
1109+
assert.strictEqual(spans[0].kind, 3);
1110+
assert.strictEqual(spans[1].name, 'test-span');
1111+
assert.strictEqual(spans[1].kind, 1);
1112+
assert.strictEqual(spans[2].name, 'pg.query:SELECT postgres');
1113+
assert.strictEqual(spans[2].kind, 3);
1114+
},
1115+
});
1116+
});
10901117
});

0 commit comments

Comments
 (0)