File tree 1 file changed +45
-0
lines changed
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 157
157
end
158
158
end
159
159
end
160
+
161
+ describe 'read preference' do
162
+ require_topology :replica_set
163
+
164
+ context 'when defined on the client' do
165
+ let ( :client_options ) do
166
+ { read : { mode : :secondary } }
167
+ end
168
+
169
+ let ( :collection_options ) do
170
+ { }
171
+ end
172
+
173
+ it 'uses the read preference defined on the client' do
174
+ collection . find . to_a
175
+ expect ( find_command . command [ '$readPreference' ] ) . to eq ( 'mode' => 'secondary' )
176
+ end
177
+
178
+ context 'when defzained on the collection' do
179
+ let ( :collection_options ) do
180
+ { read : { mode : :secondary_preferred } }
181
+ end
182
+
183
+ it 'uses the read concern defined on the collection' do
184
+ collection . find . to_a
185
+ expect ( find_command . command [ '$readPreference' ] ) . to eq ( 'mode' => 'secondaryPreferred' )
186
+ end
187
+
188
+ context 'when defined on the operation' do
189
+ let ( :collection_options ) do
190
+ { }
191
+ end
192
+
193
+ let ( :operation_read_concern ) do
194
+ { 'level' => 'available' }
195
+ end
196
+
197
+ it 'uses the read concern defined on the operation' do
198
+ collection . find ( { } , read_concern : operation_read_concern ) . to_a
199
+ expect ( find_command . command [ 'readConcern' ] ) . to eq ( operation_read_concern )
200
+ end
201
+ end
202
+ end
203
+ end
204
+ end
160
205
end
You can’t perform that action at this time.
0 commit comments