...
1# Test that setting a default write concern does not add a write concern
2# to the command sent over the wire.
3# Test operations that require 2.6+ server.
4
5data:
6 - {_id: 1, x: 11}
7 - {_id: 2, x: 22}
8collection_name: &collection_name default_write_concern_coll
9database_name: &database_name default_write_concern_db
10
11runOn:
12 - minServerVersion: "2.6"
13
14tests:
15 - description: DeleteOne omits default write concern
16 operations:
17 - name: deleteOne
18 object: collection
19 collectionOptions: {writeConcern: {}}
20 arguments:
21 filter: {}
22 result:
23 deletedCount: 1
24 expectations:
25 - command_started_event:
26 command:
27 delete: *collection_name
28 deletes:
29 - {q: {}, limit: 1}
30 writeConcern: null
31 - description: DeleteMany omits default write concern
32 operations:
33 - name: deleteMany
34 object: collection
35 collectionOptions: {writeConcern: {}}
36 arguments:
37 filter: {}
38 result:
39 deletedCount: 2
40 expectations:
41 - command_started_event:
42 command:
43 delete: *collection_name
44 deletes: [{q: {}, limit: 0}]
45 writeConcern: null
46 - description: BulkWrite with all models omits default write concern
47 operations:
48 - name: bulkWrite
49 object: collection
50 collectionOptions: {writeConcern: {}}
51 arguments:
52 ordered: true
53 requests:
54 - name: deleteMany
55 arguments:
56 filter: {}
57 - name: insertOne
58 arguments:
59 document: {_id: 1}
60 - name: updateOne
61 arguments:
62 filter: {_id: 1}
63 update: {$set: {x: 1}}
64 - name: insertOne
65 arguments:
66 document: {_id: 2}
67 - name: replaceOne
68 arguments:
69 filter: {_id: 1}
70 replacement: {x: 2}
71 - name: insertOne
72 arguments:
73 document: {_id: 3}
74 - name: updateMany
75 arguments:
76 filter: {_id: 1}
77 update: {$set: {x: 3}}
78 - name: deleteOne
79 arguments:
80 filter: {_id: 3}
81 outcome:
82 collection:
83 name: *collection_name
84 data:
85 - {_id: 1, x: 3}
86 - {_id: 2}
87 expectations:
88 - command_started_event:
89 command:
90 delete: *collection_name
91 deletes: [{q: {}, limit: 0}]
92 writeConcern: null
93 - command_started_event:
94 command:
95 insert: *collection_name
96 documents:
97 - {_id: 1}
98 writeConcern: null
99 - command_started_event:
100 command:
101 update: *collection_name
102 updates:
103 - {q: {_id: 1}, u: {$set: {x: 1}}}
104 writeConcern: null
105 - command_started_event:
106 command:
107 insert: *collection_name
108 documents:
109 - {_id: 2}
110 writeConcern: null
111 - command_started_event:
112 command:
113 update: *collection_name
114 updates:
115 - {q: {_id: 1}, u: {x: 2}}
116 writeConcern: null
117 - command_started_event:
118 command:
119 insert: *collection_name
120 documents:
121 - {_id: 3}
122 writeConcern: null
123 - command_started_event:
124 command:
125 update: *collection_name
126 updates:
127 - {q: {_id: 1}, u: {$set: {x: 3}}, multi: true}
128 writeConcern: null
129 - command_started_event:
130 command:
131 delete: *collection_name
132 deletes: [{q: {_id: 3}, limit: 1}]
133 writeConcern: null
134 - description: 'InsertOne and InsertMany omit default write concern'
135 operations:
136 - name: insertOne
137 object: collection
138 collectionOptions: {writeConcern: {}}
139 arguments:
140 document: {_id: 3}
141 - name: insertMany
142 object: collection
143 collectionOptions: {writeConcern: {}}
144 arguments:
145 documents:
146 - {_id: 4}
147 - {_id: 5}
148 outcome:
149 collection:
150 name: *collection_name
151 data:
152 - {_id: 1, x: 11}
153 - {_id: 2, x: 22}
154 - {_id: 3}
155 - {_id: 4}
156 - {_id: 5}
157 expectations:
158 - command_started_event:
159 command:
160 insert: *collection_name
161 documents:
162 - {_id: 3}
163 writeConcern: null
164 - command_started_event:
165 command:
166 insert: *collection_name
167 documents:
168 - {_id: 4}
169 - {_id: 5}
170 writeConcern: null
171 - description: 'UpdateOne, UpdateMany, and ReplaceOne omit default write concern'
172 operations:
173 - name: updateOne
174 object: collection
175 collectionOptions: {writeConcern: {}}
176 arguments:
177 filter: {_id: 1}
178 update: {$set: {x: 1}}
179 - name: updateMany
180 object: collection
181 collectionOptions: {writeConcern: {}}
182 arguments:
183 filter: {_id: 2}
184 update: {$set: {x: 2}}
185 - name: replaceOne
186 object: collection
187 collectionOptions: {writeConcern: {}}
188 arguments:
189 filter: {_id: 2}
190 replacement: {x: 3}
191 outcome:
192 collection:
193 name: *collection_name
194 data:
195 - {_id: 1, x: 1}
196 - {_id: 2, x: 3}
197 expectations:
198 - command_started_event:
199 command:
200 update: *collection_name
201 updates:
202 - {q: {_id: 1}, u: {$set: {x: 1}}}
203 writeConcern: null
204 - command_started_event:
205 command:
206 update: *collection_name
207 updates:
208 - {q: {_id: 2}, u: {$set: {x: 2}}, multi: true}
209 writeConcern: null
210 - command_started_event:
211 command:
212 update: *collection_name
213 updates:
214 - {q: {_id: 2}, u: {x: 3}}
215 writeConcern: null
View as plain text