Skip to content

Commit

Permalink
fix(NODE-4156): remove comment from commands pre-4.4 (#3195)
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson authored Apr 13, 2022
1 parent 95e1231 commit 4e6dccd
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
4 changes: 0 additions & 4 deletions src/operations/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ export abstract class CommandOperation<T> extends AbstractOperation<T> {
cmd.maxTimeMS = options.maxTimeMS;
}

if (typeof options.comment === 'string') {
cmd.comment = options.comment;
}

if (this.hasAspect(Aspect.EXPLAINABLE) && this.explain) {
if (serverWireVersion < 6 && cmd.aggregate) {
// Prior to 3.6, with aggregate, verbosity is ignored, and we must pass in "explain: true"
Expand Down
3 changes: 2 additions & 1 deletion test/integration/enumerate_collections.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const testSuite = new UnifiedTestSuiteBuilder('listCollections with comment opti
{
commandStartedEvent: {
command: {
listCollections: 1
listCollections: 1,
comment: { $$exists: false }
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions test/integration/enumerate_databases.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ const testSuite = new UnifiedTestSuiteBuilder('listDatabases with comment option
.operation({
name: 'listDatabases',
arguments: {
filter: {}
filter: {},
comment: 'string value'
},
object: 'client0'
})
Expand All @@ -166,7 +167,8 @@ const testSuite = new UnifiedTestSuiteBuilder('listDatabases with comment option
{
commandStartedEvent: {
command: {
listDatabases: 1
listDatabases: 1,
comment: { $$exists: false }
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion test/integration/enumerate_indexes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ const testSuite = new UnifiedTestSuiteBuilder('listIndexes with comment option')
events: [
{
commandStartedEvent: {
command: {}
command: {
listIndexes: 'coll0',
comment: { $$exists: false }
}
}
}
]
Expand Down
14 changes: 13 additions & 1 deletion test/tools/unified-spec-runner/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
ConnectionPoolCreatedEvent,
ConnectionReadyEvent
} from '../../../src/cmap/connection_pool_events';
import { ejson } from '../utils';
import { CmapEvent, CommandEvent, EntitiesMap } from './entities';
import { ExpectedCmapEvent, ExpectedCommandEvent, ExpectedError } from './schema';

Expand Down Expand Up @@ -253,7 +254,18 @@ export function specialCheck(
} else if (isExistsOperator(expected)) {
// $$exists
const actualExists = actual !== undefined && actual !== null;
expect((expected.$$exists && actualExists) || (!expected.$$exists && !actualExists)).to.be.true;

if (expected.$$exists) {
expect(
actualExists,
ejson`expected value at path ${path.join} to exist, but received ${actual}`
).to.be.true;
} else {
expect(
actualExists,
ejson`expected value at path ${path.join} NOT to exist, but received ${actual}`
).to.be.false;
}
} else {
expect.fail(`Unknown special operator: ${JSON.stringify(expected)}`);
}
Expand Down

0 comments on commit 4e6dccd

Please sign in to comment.