Skip to content

Commit

Permalink
fix: make test read better
Browse files Browse the repository at this point in the history
Signed-off-by: Naseem <[email protected]>
  • Loading branch information
Naseem committed Oct 6, 2020
1 parent c36c9e8 commit 9055d97
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions plugins/node/opentelemetry-plugin-mysql/test/mysql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,30 +124,34 @@ describe('[email protected]', () => {
assert.strictEqual(plugin.moduleName, 'mysql');
});

it('should name the span correctly when the query is a string', done => {
const span = provider.getTracer('default').startSpan('test span');
provider.getTracer('default').withSpan(span, () => {
const sql = 'SELECT 1+1 as solution';
const query = connection.query(sql);

query.on('end', () => {
const spans = memoryExporter.getFinishedSpans();
assert.strictEqual(spans[0].name, 'SELECT');
done();
describe('when the query is a string', () => {
it('should name the span accordingly ', done => {
const span = provider.getTracer('default').startSpan('test span');
provider.getTracer('default').withSpan(span, () => {
const sql = 'SELECT 1+1 as solution';
const query = connection.query(sql);

query.on('end', () => {
const spans = memoryExporter.getFinishedSpans();
assert.strictEqual(spans[0].name, 'SELECT');
done();
});
});
});
});

it('should name the span correctly when the query is an object', done => {
const span = provider.getTracer('default').startSpan('test span');
provider.getTracer('default').withSpan(span, () => {
const sql = 'SELECT 1+? as solution';
const query = connection.query({ sql, values: [1] });
describe('when the query is an object', () => {
it('should name the span accordingly ', done => {
const span = provider.getTracer('default').startSpan('test span');
provider.getTracer('default').withSpan(span, () => {
const sql = 'SELECT 1+? as solution';
const query = connection.query({ sql, values: [1] });

query.on('end', () => {
const spans = memoryExporter.getFinishedSpans();
assert.strictEqual(spans[0].name, sql);
done();
query.on('end', () => {
const spans = memoryExporter.getFinishedSpans();
assert.strictEqual(spans[0].name, sql);
done();
});
});
});
});
Expand Down

0 comments on commit 9055d97

Please sign in to comment.