Skip to content

Commit 3587068

Browse files
CSHARP-2978: Separate BulkWrite tests by operation
1 parent 969c59a commit 3587068

File tree

2 files changed

+126
-26
lines changed

2 files changed

+126
-26
lines changed

tests/MongoDB.Driver.Tests/Specifications/crud/tests/v2/bulkWrite-arrayFilters.json

Lines changed: 84 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"database_name": "crud-tests",
3333
"tests": [
3434
{
35-
"description": "BulkWrite with arrayFilters",
35+
"description": "BulkWrite updateOne with arrayFilters",
3636
"operations": [
3737
{
3838
"name": "bulkWrite",
@@ -53,7 +53,86 @@
5353
}
5454
]
5555
}
56-
},
56+
}
57+
],
58+
"options": {
59+
"ordered": true
60+
}
61+
},
62+
"result": {
63+
"deletedCount": 0,
64+
"insertedCount": 0,
65+
"insertedIds": {},
66+
"matchedCount": 1,
67+
"modifiedCount": 1,
68+
"upsertedCount": 0,
69+
"upsertedIds": {}
70+
}
71+
}
72+
],
73+
"expectations": [
74+
{
75+
"command_started_event": {
76+
"command": {
77+
"update": "test",
78+
"updates": [
79+
{
80+
"q": {},
81+
"u": {
82+
"$set": {
83+
"y.$[i].b": 2
84+
}
85+
},
86+
"arrayFilters": [
87+
{
88+
"i.b": 3
89+
}
90+
]
91+
}
92+
],
93+
"ordered": true
94+
},
95+
"command_name": "update",
96+
"database_name": "crud-tests"
97+
}
98+
}
99+
],
100+
"outcome": {
101+
"collection": {
102+
"data": [
103+
{
104+
"_id": 1,
105+
"y": [
106+
{
107+
"b": 2
108+
},
109+
{
110+
"b": 1
111+
}
112+
]
113+
},
114+
{
115+
"_id": 2,
116+
"y": [
117+
{
118+
"b": 0
119+
},
120+
{
121+
"b": 1
122+
}
123+
]
124+
}
125+
]
126+
}
127+
}
128+
},
129+
{
130+
"description": "BulkWrite updateMany with arrayFilters",
131+
"operations": [
132+
{
133+
"name": "bulkWrite",
134+
"arguments": {
135+
"requests": [
57136
{
58137
"name": "updateMany",
59138
"arguments": {
@@ -79,8 +158,8 @@
79158
"deletedCount": 0,
80159
"insertedCount": 0,
81160
"insertedIds": {},
82-
"matchedCount": 3,
83-
"modifiedCount": 3,
161+
"matchedCount": 2,
162+
"modifiedCount": 2,
84163
"upsertedCount": 0,
85164
"upsertedIds": {}
86165
}
@@ -92,19 +171,6 @@
92171
"command": {
93172
"update": "test",
94173
"updates": [
95-
{
96-
"q": {},
97-
"u": {
98-
"$set": {
99-
"y.$[i].b": 2
100-
}
101-
},
102-
"arrayFilters": [
103-
{
104-
"i.b": 3
105-
}
106-
]
107-
},
108174
{
109175
"q": {},
110176
"u": {
@@ -134,7 +200,7 @@
134200
"_id": 1,
135201
"y": [
136202
{
137-
"b": 2
203+
"b": 3
138204
},
139205
{
140206
"b": 2

tests/MongoDB.Driver.Tests/Specifications/crud/tests/v2/bulkWrite-arrayFilters.yml

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ database_name: &database_name "crud-tests"
1111

1212
tests:
1313
-
14-
description: "BulkWrite with arrayFilters"
14+
description: "BulkWrite updateOne with arrayFilters"
1515
operations:
1616
-
1717
name: "bulkWrite"
@@ -24,6 +24,44 @@ tests:
2424
filter: {}
2525
update: { $set: { "y.$[i].b": 2 } }
2626
arrayFilters: [ { "i.b": 3 } ]
27+
options: { ordered: true }
28+
result:
29+
deletedCount: 0
30+
insertedCount: 0
31+
insertedIds: {}
32+
matchedCount: 1
33+
modifiedCount: 1
34+
upsertedCount: 0
35+
upsertedIds: {}
36+
expectations:
37+
-
38+
command_started_event:
39+
command:
40+
update: *collection_name
41+
updates:
42+
-
43+
q: {}
44+
u: { $set: { "y.$[i].b": 2 } }
45+
arrayFilters: [ { "i.b": 3 } ]
46+
ordered: true
47+
# TODO: check that these fields do not exist once
48+
# https://jira.mongodb.org/browse/SPEC-1215 has been resolved.
49+
# writeConcern: null
50+
# bypassDocumentValidation: null
51+
command_name: update
52+
database_name: *database_name
53+
outcome:
54+
collection:
55+
data:
56+
- {_id: 1, y: [{b: 2}, {b: 1}]}
57+
- {_id: 2, y: [{b: 0}, {b: 1}]}
58+
-
59+
description: "BulkWrite updateMany with arrayFilters"
60+
operations:
61+
-
62+
name: "bulkWrite"
63+
arguments:
64+
requests:
2765
-
2866
# UpdateMany when multiple documents match arrayFilters
2967
name: "updateMany"
@@ -36,8 +74,8 @@ tests:
3674
deletedCount: 0
3775
insertedCount: 0
3876
insertedIds: {}
39-
matchedCount: 3
40-
modifiedCount: 3
77+
matchedCount: 2
78+
modifiedCount: 2
4179
upsertedCount: 0
4280
upsertedIds: {}
4381
expectations:
@@ -46,10 +84,6 @@ tests:
4684
command:
4785
update: *collection_name
4886
updates:
49-
-
50-
q: {}
51-
u: { $set: { "y.$[i].b": 2 } }
52-
arrayFilters: [ { "i.b": 3 } ]
5387
-
5488
q: {}
5589
u: { $set: { "y.$[i].b": 2 } }
@@ -65,5 +99,5 @@ tests:
6599
outcome:
66100
collection:
67101
data:
68-
- {_id: 1, y: [{b: 2}, {b: 2}]}
102+
- {_id: 1, y: [{b: 3}, {b: 2}]}
69103
- {_id: 2, y: [{b: 0}, {b: 2}]}

0 commit comments

Comments
 (0)