Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(plugin-mongodb-core): add missing codecov script #601

Merged
merged 3 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/opentelemetry-plugin-mongodb-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"repository": "open-telemetry/opentelemetry-js",
"scripts": {
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.ts'",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
"tdd": "yarn test -- --watch-extensions ts --watch",
"clean": "rimraf build/*",
"check": "gts check",
Expand Down Expand Up @@ -40,8 +41,8 @@
"access": "public"
},
"devDependencies": {
"@opentelemetry/node": "^0.1.1",
"@opentelemetry/tracing": "^0.1.1",
"@opentelemetry/node": "^0.2.0",
"@opentelemetry/tracing": "^0.2.0",
"@types/mocha": "^5.2.7",
"@types/mongodb": "^3.2.3",
"@types/node": "^12.7.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-plugin-mongodb-core/src/mongodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class MongoDBCorePlugin extends BasePlugin<typeof mongodb> {
const resultHandler =
typeof options === 'function' ? options : callback;
if (
currentSpan === null ||
currentSpan === undefined ||
typeof resultHandler !== 'function' ||
typeof commands !== 'object'
) {
Expand Down Expand Up @@ -208,7 +208,7 @@ export class MongoDBCorePlugin extends BasePlugin<typeof mongodb> {
): mongodb.Cursor {
const currentSpan = plugin._tracer.getCurrentSpan();
const resultHandler = args[0];
if (currentSpan === null || typeof resultHandler !== 'function') {
if (currentSpan === undefined || typeof resultHandler !== 'function') {
return original.apply(this, args);
}
const span = plugin._tracer.startSpan(`mongodb.query`, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class AsyncHooksScopeManager implements ScopeManager {
}

active(): unknown {
return this._scopes[asyncHooks.executionAsyncId()] || null;
return this._scopes[asyncHooks.executionAsyncId()] || undefined;
}

with<T extends (...args: unknown[]) => ReturnType<T>>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('AsyncHooksScopeManager', () => {
setTimeout(() => {
assert.strictEqual(
scopeManager.active(),
null,
undefined,
'should have no scope'
);
return done();
Expand Down Expand Up @@ -228,7 +228,7 @@ describe('AsyncHooksScopeManager', () => {
const patchedEe = scopeManager.bind(ee, scope);
const handler = () => {
setImmediate(() => {
assert.deepStrictEqual(scopeManager.active(), null);
assert.deepStrictEqual(scopeManager.active(), undefined);
patchedEe.removeAllListeners('test');
assert.strictEqual(patchedEe.listeners('test').length, 0);
return done();
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-scope-base/src/NoopScopeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import * as types from './types';

export class NoopScopeManager implements types.ScopeManager {
active(): unknown {
return null;
return undefined;
}

with<T extends (...args: unknown[]) => ReturnType<T>>(
Expand Down
14 changes: 11 additions & 3 deletions packages/opentelemetry-scope-base/test/NoopScopeManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('NoopScopeManager', () => {
scopeManager.with(test, () => {
assert.strictEqual(
scopeManager.active(),
null,
undefined,
'should not have scope'
);
return done();
Expand All @@ -66,12 +66,20 @@ describe('NoopScopeManager', () => {

describe('.active()', () => {
it('should always return null (when enabled)', () => {
assert.strictEqual(scopeManager.active(), null, 'should not have scope');
assert.strictEqual(
scopeManager.active(),
undefined,
'should not have scope'
);
});

it('should always return null (when disabled)', () => {
scopeManager.disable();
assert.strictEqual(scopeManager.active(), null, 'should not have scope');
assert.strictEqual(
scopeManager.active(),
undefined,
'should not have scope'
);
scopeManager.enable();
});
});
Expand Down