1{
2 "description": "aggregate-let",
3 "schemaVersion": "1.4",
4 "createEntities": [
5 {
6 "client": {
7 "id": "client0",
8 "observeEvents": [
9 "commandStartedEvent"
10 ]
11 }
12 },
13 {
14 "database": {
15 "id": "database0",
16 "client": "client0",
17 "databaseName": "crud-tests"
18 }
19 },
20 {
21 "collection": {
22 "id": "collection0",
23 "database": "database0",
24 "collectionName": "coll0"
25 }
26 },
27 {
28 "collection": {
29 "id": "collection1",
30 "database": "database0",
31 "collectionName": "coll1"
32 }
33 }
34 ],
35 "initialData": [
36 {
37 "collectionName": "coll0",
38 "databaseName": "crud-tests",
39 "documents": [
40 {
41 "_id": 1
42 }
43 ]
44 },
45 {
46 "collectionName": "coll1",
47 "databaseName": "crud-tests",
48 "documents": []
49 }
50 ],
51 "tests": [
52 {
53 "description": "Aggregate with let option",
54 "runOnRequirements": [
55 {
56 "minServerVersion": "5.0"
57 }
58 ],
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 unsupported (server-side error)",
153 "runOnRequirements": [
154 {
155 "minServerVersion": "2.6.0",
156 "maxServerVersion": "4.4.99"
157 }
158 ],
159 "operations": [
160 {
161 "name": "aggregate",
162 "object": "collection0",
163 "arguments": {
164 "pipeline": [
165 {
166 "$match": {
167 "_id": 1
168 }
169 }
170 ],
171 "let": {
172 "x": "foo"
173 }
174 },
175 "expectError": {
176 "errorContains": "unrecognized field 'let'",
177 "isClientError": false
178 }
179 }
180 ],
181 "expectEvents": [
182 {
183 "client": "client0",
184 "events": [
185 {
186 "commandStartedEvent": {
187 "command": {
188 "aggregate": "coll0",
189 "pipeline": [
190 {
191 "$match": {
192 "_id": 1
193 }
194 }
195 ],
196 "let": {
197 "x": "foo"
198 }
199 }
200 }
201 }
202 ]
203 }
204 ]
205 },
206 {
207 "description": "Aggregate to collection with let option",
208 "runOnRequirements": [
209 {
210 "minServerVersion": "5.0",
211 "serverless": "forbid"
212 }
213 ],
214 "operations": [
215 {
216 "name": "aggregate",
217 "object": "collection0",
218 "arguments": {
219 "pipeline": [
220 {
221 "$match": {
222 "$expr": {
223 "$eq": [
224 "$_id",
225 "$$id"
226 ]
227 }
228 }
229 },
230 {
231 "$project": {
232 "_id": 1
233 }
234 },
235 {
236 "$out": "coll1"
237 }
238 ],
239 "let": {
240 "id": 1
241 }
242 }
243 }
244 ],
245 "expectEvents": [
246 {
247 "client": "client0",
248 "events": [
249 {
250 "commandStartedEvent": {
251 "command": {
252 "aggregate": "coll0",
253 "pipeline": [
254 {
255 "$match": {
256 "$expr": {
257 "$eq": [
258 "$_id",
259 "$$id"
260 ]
261 }
262 }
263 },
264 {
265 "$project": {
266 "_id": 1
267 }
268 },
269 {
270 "$out": "coll1"
271 }
272 ],
273 "let": {
274 "id": 1
275 }
276 }
277 }
278 }
279 ]
280 }
281 ],
282 "outcome": [
283 {
284 "collectionName": "coll1",
285 "databaseName": "crud-tests",
286 "documents": [
287 {
288 "_id": 1
289 }
290 ]
291 }
292 ]
293 },
294 {
295 "description": "Aggregate to collection with let option unsupported (server-side error)",
296 "runOnRequirements": [
297 {
298 "minServerVersion": "2.6.0",
299 "maxServerVersion": "4.4.99"
300 }
301 ],
302 "operations": [
303 {
304 "name": "aggregate",
305 "object": "collection0",
306 "arguments": {
307 "pipeline": [
308 {
309 "$match": {
310 "$expr": {
311 "$eq": [
312 "$_id",
313 "$$id"
314 ]
315 }
316 }
317 },
318 {
319 "$project": {
320 "_id": 1
321 }
322 },
323 {
324 "$out": "coll1"
325 }
326 ],
327 "let": {
328 "id": 1
329 }
330 },
331 "expectError": {
332 "errorContains": "unrecognized field 'let'",
333 "isClientError": false
334 }
335 }
336 ],
337 "expectEvents": [
338 {
339 "client": "client0",
340 "events": [
341 {
342 "commandStartedEvent": {
343 "command": {
344 "aggregate": "coll0",
345 "pipeline": [
346 {
347 "$match": {
348 "$expr": {
349 "$eq": [
350 "$_id",
351 "$$id"
352 ]
353 }
354 }
355 },
356 {
357 "$project": {
358 "_id": 1
359 }
360 },
361 {
362 "$out": "coll1"
363 }
364 ],
365 "let": {
366 "id": 1
367 }
368 }
369 }
370 }
371 ]
372 }
373 ]
374 }
375 ]
376}
View as plain text