Skip to content

Commit 36189eb

Browse files
authored
CDRIVER-3895: Sync CRUD tests for dots/dollars (#809)
Synced with mongodb/specifications@fc21cb7 Note: this also pulls in test changes relevant to aggregate let support (CDRIVER-4010)
1 parent d58b2d8 commit 36189eb

File tree

2 files changed

+283
-6
lines changed

2 files changed

+283
-6
lines changed

src/libmongoc/tests/json/crud/unified/aggregate-let.json

Lines changed: 283 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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": [
@@ -44,6 +56,109 @@
4456
"minServerVersion": "5.0"
4557
}
4658
],
59+
"operations": [
60+
{
61+
"name": "aggregate",
62+
"object": "collection0",
63+
"arguments": {
64+
"pipeline": [
65+
{
66+
"$match": {
67+
"$expr": {
68+
"$eq": [
69+
"$_id",
70+
"$$id"
71+
]
72+
}
73+
}
74+
},
75+
{
76+
"$project": {
77+
"_id": 0,
78+
"x": "$$x",
79+
"y": "$$y",
80+
"rand": "$$rand"
81+
}
82+
}
83+
],
84+
"let": {
85+
"id": 1,
86+
"x": "foo",
87+
"y": {
88+
"$literal": "bar"
89+
},
90+
"rand": {
91+
"$rand": {}
92+
}
93+
}
94+
},
95+
"expectResult": [
96+
{
97+
"x": "foo",
98+
"y": "bar",
99+
"rand": {
100+
"$$type": "double"
101+
}
102+
}
103+
]
104+
}
105+
],
106+
"expectEvents": [
107+
{
108+
"client": "client0",
109+
"events": [
110+
{
111+
"commandStartedEvent": {
112+
"command": {
113+
"aggregate": "coll0",
114+
"pipeline": [
115+
{
116+
"$match": {
117+
"$expr": {
118+
"$eq": [
119+
"$_id",
120+
"$$id"
121+
]
122+
}
123+
}
124+
},
125+
{
126+
"$project": {
127+
"_id": 0,
128+
"x": "$$x",
129+
"y": "$$y",
130+
"rand": "$$rand"
131+
}
132+
}
133+
],
134+
"let": {
135+
"id": 1,
136+
"x": "foo",
137+
"y": {
138+
"$literal": "bar"
139+
},
140+
"rand": {
141+
"$rand": {}
142+
}
143+
}
144+
}
145+
}
146+
}
147+
]
148+
}
149+
]
150+
},
151+
{
152+
"description": "Aggregate with let option and dollar-prefixed $literal value",
153+
"runOnRequirements": [
154+
{
155+
"minServerVersion": "5.0",
156+
"topologies": [
157+
"single",
158+
"replicaset"
159+
]
160+
}
161+
],
47162
"operations": [
48163
{
49164
"name": "aggregate",
@@ -190,6 +305,174 @@
190305
]
191306
}
192307
]
308+
},
309+
{
310+
"description": "Aggregate to collection with let option",
311+
"runOnRequirements": [
312+
{
313+
"minServerVersion": "5.0"
314+
}
315+
],
316+
"operations": [
317+
{
318+
"name": "aggregate",
319+
"object": "collection0",
320+
"arguments": {
321+
"pipeline": [
322+
{
323+
"$match": {
324+
"$expr": {
325+
"$eq": [
326+
"$_id",
327+
"$$id"
328+
]
329+
}
330+
}
331+
},
332+
{
333+
"$project": {
334+
"_id": 1
335+
}
336+
},
337+
{
338+
"$out": "coll1"
339+
}
340+
],
341+
"let": {
342+
"id": 1
343+
}
344+
}
345+
}
346+
],
347+
"expectEvents": [
348+
{
349+
"client": "client0",
350+
"events": [
351+
{
352+
"commandStartedEvent": {
353+
"command": {
354+
"aggregate": "coll0",
355+
"pipeline": [
356+
{
357+
"$match": {
358+
"$expr": {
359+
"$eq": [
360+
"$_id",
361+
"$$id"
362+
]
363+
}
364+
}
365+
},
366+
{
367+
"$project": {
368+
"_id": 1
369+
}
370+
},
371+
{
372+
"$out": "coll1"
373+
}
374+
],
375+
"let": {
376+
"id": 1
377+
}
378+
}
379+
}
380+
}
381+
]
382+
}
383+
],
384+
"outcome": [
385+
{
386+
"collectionName": "coll1",
387+
"databaseName": "crud-tests",
388+
"documents": [
389+
{
390+
"_id": 1
391+
}
392+
]
393+
}
394+
]
395+
},
396+
{
397+
"description": "Aggregate to collection with let option unsupported (server-side error)",
398+
"runOnRequirements": [
399+
{
400+
"minServerVersion": "2.6.0",
401+
"maxServerVersion": "4.4.99"
402+
}
403+
],
404+
"operations": [
405+
{
406+
"name": "aggregate",
407+
"object": "collection0",
408+
"arguments": {
409+
"pipeline": [
410+
{
411+
"$match": {
412+
"$expr": {
413+
"$eq": [
414+
"$_id",
415+
"$$id"
416+
]
417+
}
418+
}
419+
},
420+
{
421+
"$project": {
422+
"_id": 1
423+
}
424+
},
425+
{
426+
"$out": "coll1"
427+
}
428+
],
429+
"let": {
430+
"id": 1
431+
}
432+
},
433+
"expectError": {
434+
"errorContains": "unrecognized field 'let'",
435+
"isClientError": false
436+
}
437+
}
438+
],
439+
"expectEvents": [
440+
{
441+
"client": "client0",
442+
"events": [
443+
{
444+
"commandStartedEvent": {
445+
"command": {
446+
"aggregate": "coll0",
447+
"pipeline": [
448+
{
449+
"$match": {
450+
"$expr": {
451+
"$eq": [
452+
"$_id",
453+
"$$id"
454+
]
455+
}
456+
}
457+
},
458+
{
459+
"$project": {
460+
"_id": 1
461+
}
462+
},
463+
{
464+
"$out": "coll1"
465+
}
466+
],
467+
"let": {
468+
"id": 1
469+
}
470+
}
471+
}
472+
}
473+
]
474+
}
475+
]
193476
}
194477
]
195478
}

src/libmongoc/tests/json/crud/unified/insertOne-dots_and_dollars.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
}
6464
},
6565
"expectResult": {
66-
"insertedCount": 1,
6766
"insertedId": {
6867
"$$unsetOrMatches": 1
6968
}
@@ -166,7 +165,6 @@
166165
}
167166
},
168167
"expectResult": {
169-
"insertedCount": 1,
170168
"insertedId": {
171169
"$$unsetOrMatches": 1
172170
}
@@ -221,7 +219,6 @@
221219
}
222220
},
223221
"expectResult": {
224-
"insertedCount": 1,
225222
"insertedId": {
226223
"$$unsetOrMatches": 1
227224
}
@@ -280,7 +277,6 @@
280277
}
281278
},
282279
"expectResult": {
283-
"insertedCount": 1,
284280
"insertedId": {
285281
"$$unsetOrMatches": 1
286282
}
@@ -390,7 +386,6 @@
390386
}
391387
},
392388
"expectResult": {
393-
"insertedCount": 1,
394389
"insertedId": {
395390
"$$unsetOrMatches": {
396391
"a.b": 1
@@ -501,7 +496,6 @@
501496
}
502497
},
503498
"expectResult": {
504-
"insertedCount": 1,
505499
"insertedId": {
506500
"$$unsetOrMatches": 1
507501
}

0 commit comments

Comments
 (0)