Skip to content

Commit d270610

Browse files
authored
test(NODE-3412): sync spec tests for serverless testing (#2911)
1 parent 51ea86d commit d270610

File tree

331 files changed

+16364
-11231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

331 files changed

+16364
-11231
lines changed

src/collection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,11 +1237,11 @@ export class Collection<TSchema extends Document = Document> {
12371237
* @param callback - An optional callback, a Promise will be returned if none is provided
12381238
*/
12391239
findOneAndDelete(filter: Filter<TSchema>): Promise<ModifyResult<TSchema>>;
1240-
findOneAndDelete(filter: Filter<TSchema>, callback: Callback<ModifyResult<TSchema>>): void;
12411240
findOneAndDelete(
12421241
filter: Filter<TSchema>,
12431242
options: FindOneAndDeleteOptions
12441243
): Promise<ModifyResult<TSchema>>;
1244+
findOneAndDelete(filter: Filter<TSchema>, callback: Callback<ModifyResult<TSchema>>): void;
12451245
findOneAndDelete(
12461246
filter: Filter<TSchema>,
12471247
options: FindOneAndDeleteOptions,

test/functional/crud_spec.test.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ const chai = require('chai');
66
const expect = chai.expect;
77
chai.use(require('chai-subset'));
88

9-
const TestRunnerContext = require('./spec-runner').TestRunnerContext;
10-
const gatherTestSuites = require('./spec-runner').gatherTestSuites;
11-
const generateTopologyTests = require('./spec-runner').generateTopologyTests;
12-
139
const { loadSpecTests } = require('../spec/index');
1410
const { runUnifiedTest } = require('./unified-spec-runner/runner');
1511

@@ -425,17 +421,6 @@ describe('CRUD spec', function () {
425421
}
426422
});
427423

428-
describe('CRUD v2', function () {
429-
const testContext = new TestRunnerContext();
430-
const testSuites = gatherTestSuites(path.resolve(__dirname, '../spec/crud/v2'));
431-
after(() => testContext.teardown());
432-
before(function () {
433-
return testContext.setup(this.configuration);
434-
});
435-
436-
generateTopologyTests(testSuites, testContext);
437-
});
438-
439424
describe('CRUD unified', function () {
440425
for (const crudSpecTest of loadSpecTests('crud/unified')) {
441426
expect(crudSpecTest).to.exist;

test/functional/unified-spec-runner/operations.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ operations.set('findOneAndUpdate', async ({ entities, operation }) => {
270270
return (await collection.findOneAndUpdate(filter, update, translateOptions(opts))).value;
271271
});
272272

273+
operations.set('findOneAndDelete', async ({ entities, operation }) => {
274+
const collection = entities.getEntity('collection', operation.object);
275+
const { filter, ...opts } = operation.arguments;
276+
return (await collection.findOneAndDelete(filter, opts)).value;
277+
});
278+
273279
operations.set('failPoint', async ({ entities, operation }) => {
274280
const client = entities.getEntity('client', operation.arguments.client);
275281
return entities.failPoints.enableFailPoint(client, operation.arguments.failPoint);
@@ -409,12 +415,6 @@ operations.set('estimatedDocumentCount', async ({ entities, operation }) => {
409415
return collection.estimatedDocumentCount(operation.arguments);
410416
});
411417

412-
operations.set('findOneAndDelete', async ({ entities, operation }) => {
413-
const collection = entities.getEntity('collection', operation.object);
414-
const { filter, ...opts } = operation.arguments;
415-
return collection.findOneAndDelete(filter, opts);
416-
});
417-
418418
operations.set('runCommand', async ({ entities, operation }: OperationFunctionParams) => {
419419
const db = entities.getEntity('db', operation.object);
420420
const { command, ...opts } = operation.arguments;

test/spec/crud/unified/aggregate-let.json

Lines changed: 182 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "aggregate-let",
3-
"schemaVersion": "1.0",
3+
"schemaVersion": "1.4",
44
"createEntities": [
55
{
66
"client": {
@@ -23,6 +23,13 @@
2323
"database": "database0",
2424
"collectionName": "coll0"
2525
}
26+
},
27+
{
28+
"collection": {
29+
"id": "collection1",
30+
"database": "database0",
31+
"collectionName": "coll1"
32+
}
2633
}
2734
],
2835
"initialData": [
@@ -34,6 +41,11 @@
3441
"_id": 1
3542
}
3643
]
44+
},
45+
{
46+
"collectionName": "coll1",
47+
"databaseName": "crud-tests",
48+
"documents": []
3749
}
3850
],
3951
"tests": [
@@ -293,6 +305,175 @@
293305
]
294306
}
295307
]
308+
},
309+
{
310+
"description": "Aggregate to collection with let option",
311+
"runOnRequirements": [
312+
{
313+
"minServerVersion": "5.0",
314+
"serverless": "forbid"
315+
}
316+
],
317+
"operations": [
318+
{
319+
"name": "aggregate",
320+
"object": "collection0",
321+
"arguments": {
322+
"pipeline": [
323+
{
324+
"$match": {
325+
"$expr": {
326+
"$eq": [
327+
"$_id",
328+
"$$id"
329+
]
330+
}
331+
}
332+
},
333+
{
334+
"$project": {
335+
"_id": 1
336+
}
337+
},
338+
{
339+
"$out": "coll1"
340+
}
341+
],
342+
"let": {
343+
"id": 1
344+
}
345+
}
346+
}
347+
],
348+
"expectEvents": [
349+
{
350+
"client": "client0",
351+
"events": [
352+
{
353+
"commandStartedEvent": {
354+
"command": {
355+
"aggregate": "coll0",
356+
"pipeline": [
357+
{
358+
"$match": {
359+
"$expr": {
360+
"$eq": [
361+
"$_id",
362+
"$$id"
363+
]
364+
}
365+
}
366+
},
367+
{
368+
"$project": {
369+
"_id": 1
370+
}
371+
},
372+
{
373+
"$out": "coll1"
374+
}
375+
],
376+
"let": {
377+
"id": 1
378+
}
379+
}
380+
}
381+
}
382+
]
383+
}
384+
],
385+
"outcome": [
386+
{
387+
"collectionName": "coll1",
388+
"databaseName": "crud-tests",
389+
"documents": [
390+
{
391+
"_id": 1
392+
}
393+
]
394+
}
395+
]
396+
},
397+
{
398+
"description": "Aggregate to collection with let option unsupported (server-side error)",
399+
"runOnRequirements": [
400+
{
401+
"minServerVersion": "2.6.0",
402+
"maxServerVersion": "4.4.99"
403+
}
404+
],
405+
"operations": [
406+
{
407+
"name": "aggregate",
408+
"object": "collection0",
409+
"arguments": {
410+
"pipeline": [
411+
{
412+
"$match": {
413+
"$expr": {
414+
"$eq": [
415+
"$_id",
416+
"$$id"
417+
]
418+
}
419+
}
420+
},
421+
{
422+
"$project": {
423+
"_id": 1
424+
}
425+
},
426+
{
427+
"$out": "coll1"
428+
}
429+
],
430+
"let": {
431+
"id": 1
432+
}
433+
},
434+
"expectError": {
435+
"errorContains": "unrecognized field 'let'",
436+
"isClientError": false
437+
}
438+
}
439+
],
440+
"expectEvents": [
441+
{
442+
"client": "client0",
443+
"events": [
444+
{
445+
"commandStartedEvent": {
446+
"command": {
447+
"aggregate": "coll0",
448+
"pipeline": [
449+
{
450+
"$match": {
451+
"$expr": {
452+
"$eq": [
453+
"$_id",
454+
"$$id"
455+
]
456+
}
457+
}
458+
},
459+
{
460+
"$project": {
461+
"_id": 1
462+
}
463+
},
464+
{
465+
"$out": "coll1"
466+
}
467+
],
468+
"let": {
469+
"id": 1
470+
}
471+
}
472+
}
473+
}
474+
]
475+
}
476+
]
296477
}
297478
]
298479
}

test/spec/crud/unified/aggregate-let.yml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
description: "aggregate-let"
22

3-
schemaVersion: "1.0"
3+
schemaVersion: "1.4"
44

55
createEntities:
66
- client:
@@ -14,12 +14,19 @@ createEntities:
1414
id: &collection0 collection0
1515
database: *database0
1616
collectionName: &collection0Name coll0
17+
- collection:
18+
id: &collection1 collection1
19+
database: *database0
20+
collectionName: &collection1Name coll1
1721

1822
initialData: &initialData
1923
- collectionName: *collection0Name
2024
databaseName: *database0Name
2125
documents:
2226
- { _id: 1 }
27+
- collectionName: *collection1Name
28+
databaseName: *database0Name
29+
documents: [ ]
2330

2431
tests:
2532
# TODO: Once SERVER-57403 is resolved, this test can be removed in favor of
@@ -115,3 +122,53 @@ tests:
115122
aggregate: *collection0Name
116123
pipeline: *pipeline1
117124
let: *let1
125+
126+
- description: "Aggregate to collection with let option"
127+
runOnRequirements:
128+
- minServerVersion: "5.0"
129+
serverless: "forbid"
130+
operations:
131+
- name: aggregate
132+
object: *collection0
133+
arguments:
134+
pipeline: &pipeline2
135+
- $match: { $expr: { $eq: ["$_id", "$$id"] } }
136+
- $project: { _id: 1 }
137+
- $out: *collection1Name
138+
let: &let2
139+
id: 1
140+
expectEvents:
141+
- client: *client0
142+
events:
143+
- commandStartedEvent:
144+
command:
145+
aggregate: *collection0Name
146+
pipeline: *pipeline2
147+
let: *let2
148+
outcome:
149+
- collectionName: *collection1Name
150+
databaseName: *database0Name
151+
documents:
152+
- { _id: 1 }
153+
154+
- description: "Aggregate to collection with let option unsupported (server-side error)"
155+
runOnRequirements:
156+
- minServerVersion: "2.6.0"
157+
maxServerVersion: "4.4.99"
158+
operations:
159+
- name: aggregate
160+
object: *collection0
161+
arguments:
162+
pipeline: *pipeline2
163+
let: *let2
164+
expectError:
165+
errorContains: "unrecognized field 'let'"
166+
isClientError: false
167+
expectEvents:
168+
- client: *client0
169+
events:
170+
- commandStartedEvent:
171+
command:
172+
aggregate: *collection0Name
173+
pipeline: *pipeline2
174+
let: *let2

0 commit comments

Comments
 (0)