Skip to content

Commit 4e6dccd

Browse files
fix(NODE-4156): remove comment from commands pre-4.4 (#3195)
1 parent 95e1231 commit 4e6dccd

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

src/operations/command.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,6 @@ export abstract class CommandOperation<T> extends AbstractOperation<T> {
179179
cmd.maxTimeMS = options.maxTimeMS;
180180
}
181181

182-
if (typeof options.comment === 'string') {
183-
cmd.comment = options.comment;
184-
}
185-
186182
if (this.hasAspect(Aspect.EXPLAINABLE) && this.explain) {
187183
if (serverWireVersion < 6 && cmd.aggregate) {
188184
// Prior to 3.6, with aggregate, verbosity is ignored, and we must pass in "explain: true"

test/integration/enumerate_collections.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ const testSuite = new UnifiedTestSuiteBuilder('listCollections with comment opti
2525
{
2626
commandStartedEvent: {
2727
command: {
28-
listCollections: 1
28+
listCollections: 1,
29+
comment: { $$exists: false }
2930
}
3031
}
3132
}

test/integration/enumerate_databases.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ const testSuite = new UnifiedTestSuiteBuilder('listDatabases with comment option
156156
.operation({
157157
name: 'listDatabases',
158158
arguments: {
159-
filter: {}
159+
filter: {},
160+
comment: 'string value'
160161
},
161162
object: 'client0'
162163
})
@@ -166,7 +167,8 @@ const testSuite = new UnifiedTestSuiteBuilder('listDatabases with comment option
166167
{
167168
commandStartedEvent: {
168169
command: {
169-
listDatabases: 1
170+
listDatabases: 1,
171+
comment: { $$exists: false }
170172
}
171173
}
172174
}

test/integration/enumerate_indexes.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ const testSuite = new UnifiedTestSuiteBuilder('listIndexes with comment option')
2424
events: [
2525
{
2626
commandStartedEvent: {
27-
command: {}
27+
command: {
28+
listIndexes: 'coll0',
29+
comment: { $$exists: false }
30+
}
2831
}
2932
}
3033
]

test/tools/unified-spec-runner/match.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
ConnectionPoolCreatedEvent,
2020
ConnectionReadyEvent
2121
} from '../../../src/cmap/connection_pool_events';
22+
import { ejson } from '../utils';
2223
import { CmapEvent, CommandEvent, EntitiesMap } from './entities';
2324
import { ExpectedCmapEvent, ExpectedCommandEvent, ExpectedError } from './schema';
2425

@@ -253,7 +254,18 @@ export function specialCheck(
253254
} else if (isExistsOperator(expected)) {
254255
// $$exists
255256
const actualExists = actual !== undefined && actual !== null;
256-
expect((expected.$$exists && actualExists) || (!expected.$$exists && !actualExists)).to.be.true;
257+
258+
if (expected.$$exists) {
259+
expect(
260+
actualExists,
261+
ejson`expected value at path ${path.join} to exist, but received ${actual}`
262+
).to.be.true;
263+
} else {
264+
expect(
265+
actualExists,
266+
ejson`expected value at path ${path.join} NOT to exist, but received ${actual}`
267+
).to.be.false;
268+
}
257269
} else {
258270
expect.fail(`Unknown special operator: ${JSON.stringify(expected)}`);
259271
}

0 commit comments

Comments
 (0)