Skip to content

Commit 25d22b2

Browse files
test(NODE-3698): sync spec tests for crud operations with let option (#3147)
1 parent f76635a commit 25d22b2

18 files changed

+2327
-139
lines changed

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

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -56,109 +56,6 @@
5656
"minServerVersion": "5.0"
5757
}
5858
],
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-
],
16259
"operations": [
16360
{
16461
"name": "aggregate",

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

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,45 +29,9 @@ initialData: &initialData
2929
documents: [ ]
3030

3131
tests:
32-
# TODO: Once SERVER-57403 is resolved, this test can be removed in favor of
33-
# the "dollar-prefixed $literal value" test below.
3432
- description: "Aggregate with let option"
3533
runOnRequirements:
3634
- minServerVersion: "5.0"
37-
operations:
38-
- name: aggregate
39-
object: *collection0
40-
arguments:
41-
pipeline: &pipeline0
42-
# $match takes a query expression, so $expr is necessary to utilize
43-
# an aggregate expression context and access "let" variables.
44-
- $match: { $expr: { $eq: ["$_id", "$$id"] } }
45-
- $project: { _id: 0, x: "$$x", y: "$$y", rand: "$$rand" }
46-
# Values in "let" must be constant or closed expressions that do not
47-
# depend on document values. This test demonstrates a basic constant
48-
# value, a value wrapped with $literal (to avoid expression parsing),
49-
# and a closed expression (e.g. $rand).
50-
let: &let0
51-
id: 1
52-
x: foo
53-
y: { $literal: "bar" }
54-
rand: { $rand: {} }
55-
expectResult:
56-
- { x: "foo", y: "bar", rand: { $$type: "double" } }
57-
expectEvents:
58-
- client: *client0
59-
events:
60-
- commandStartedEvent:
61-
command:
62-
aggregate: *collection0Name
63-
pipeline: *pipeline0
64-
let: *let0
65-
66-
- description: "Aggregate with let option and dollar-prefixed $literal value"
67-
runOnRequirements:
68-
- minServerVersion: "5.0"
69-
# TODO: Remove topology restrictions once SERVER-57403 is resolved
70-
topologies: ["single", "replicaset"]
7135
operations:
7236
- name: aggregate
7337
object: *collection0
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
{
2+
"description": "deleteMany-let",
3+
"schemaVersion": "1.0",
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+
"initialData": [
29+
{
30+
"collectionName": "coll0",
31+
"databaseName": "crud-tests",
32+
"documents": [
33+
{
34+
"_id": 1
35+
},
36+
{
37+
"_id": 2,
38+
"name": "name"
39+
},
40+
{
41+
"_id": 3,
42+
"name": "name"
43+
}
44+
]
45+
}
46+
],
47+
"tests": [
48+
{
49+
"description": "deleteMany with let option",
50+
"runOnRequirements": [
51+
{
52+
"minServerVersion": "5.0"
53+
}
54+
],
55+
"operations": [
56+
{
57+
"name": "deleteMany",
58+
"object": "collection0",
59+
"arguments": {
60+
"filter": {
61+
"$expr": {
62+
"$eq": [
63+
"$name",
64+
"$$name"
65+
]
66+
}
67+
},
68+
"let": {
69+
"name": "name"
70+
}
71+
},
72+
"expectResult": {
73+
"deletedCount": 2
74+
}
75+
}
76+
],
77+
"expectEvents": [
78+
{
79+
"client": "client0",
80+
"events": [
81+
{
82+
"commandStartedEvent": {
83+
"command": {
84+
"delete": "coll0",
85+
"deletes": [
86+
{
87+
"q": {
88+
"$expr": {
89+
"$eq": [
90+
"$name",
91+
"$$name"
92+
]
93+
}
94+
},
95+
"limit": 0
96+
}
97+
],
98+
"let": {
99+
"name": "name"
100+
}
101+
}
102+
}
103+
}
104+
]
105+
}
106+
],
107+
"outcome": [
108+
{
109+
"collectionName": "coll0",
110+
"databaseName": "crud-tests",
111+
"documents": [
112+
{
113+
"_id": 1
114+
}
115+
]
116+
}
117+
]
118+
},
119+
{
120+
"description": "deleteMany with let option unsupported (server-side error)",
121+
"runOnRequirements": [
122+
{
123+
"minServerVersion": "3.6.0",
124+
"maxServerVersion": "4.4.99"
125+
}
126+
],
127+
"operations": [
128+
{
129+
"name": "deleteMany",
130+
"object": "collection0",
131+
"arguments": {
132+
"filter": {
133+
"$expr": {
134+
"$eq": [
135+
"$name",
136+
"$$name"
137+
]
138+
}
139+
},
140+
"let": {
141+
"name": "name"
142+
}
143+
},
144+
"expectError": {
145+
"errorContains": "'delete.let' is an unknown field",
146+
"isClientError": false
147+
}
148+
}
149+
],
150+
"expectEvents": [
151+
{
152+
"client": "client0",
153+
"events": [
154+
{
155+
"commandStartedEvent": {
156+
"command": {
157+
"delete": "coll0",
158+
"deletes": [
159+
{
160+
"q": {
161+
"$expr": {
162+
"$eq": [
163+
"$name",
164+
"$$name"
165+
]
166+
}
167+
},
168+
"limit": 0
169+
}
170+
],
171+
"let": {
172+
"name": "name"
173+
}
174+
}
175+
}
176+
}
177+
]
178+
}
179+
],
180+
"outcome": [
181+
{
182+
"collectionName": "coll0",
183+
"databaseName": "crud-tests",
184+
"documents": [
185+
{
186+
"_id": 1
187+
},
188+
{
189+
"_id": 2,
190+
"name": "name"
191+
},
192+
{
193+
"_id": 3,
194+
"name": "name"
195+
}
196+
]
197+
}
198+
]
199+
}
200+
]
201+
}

0 commit comments

Comments
 (0)