File tree Expand file tree Collapse file tree 2 files changed +39
-6
lines changed Expand file tree Collapse file tree 2 files changed +39
-6
lines changed Original file line number Diff line number Diff line change @@ -135,12 +135,14 @@ where
135
135
let result = self . provider . execute ( spec, client, pin) . await ;
136
136
self . handle_get_more_result ( result) ?;
137
137
138
- if self . is_exhausted ( ) {
139
- Ok ( AdvanceResult :: Exhausted )
140
- } else {
141
- match self . state_mut ( ) . buffer . advance ( ) {
142
- true => Ok ( AdvanceResult :: Advanced ) ,
143
- false => Ok ( AdvanceResult :: Waiting ) ,
138
+ match self . state_mut ( ) . buffer . advance ( ) {
139
+ true => Ok ( AdvanceResult :: Advanced ) ,
140
+ false => {
141
+ if self . is_exhausted ( ) {
142
+ Ok ( AdvanceResult :: Exhausted )
143
+ } else {
144
+ Ok ( AdvanceResult :: Waiting )
145
+ }
144
146
}
145
147
}
146
148
}
Original file line number Diff line number Diff line change @@ -257,3 +257,34 @@ async fn session_cursor_with_type() {
257
257
258
258
let _ = cursor_with_type. next ( & mut session) . await . unwrap ( ) . unwrap ( ) ;
259
259
}
260
+
261
+ #[ cfg_attr( feature = "tokio-runtime" , tokio:: test) ]
262
+ #[ cfg_attr( feature = "async-std-runtime" , async_std:: test) ]
263
+ async fn cursor_final_batch ( ) {
264
+ let client = TestClient :: new ( ) . await ;
265
+ let coll = client
266
+ . create_fresh_collection ( "test_cursor_final_batch" , "test" , None )
267
+ . await ;
268
+ coll. insert_many (
269
+ vec ! [
270
+ doc! { "foo" : 1 } ,
271
+ doc! { "foo" : 2 } ,
272
+ doc! { "foo" : 3 } ,
273
+ doc! { "foo" : 4 } ,
274
+ doc! { "foo" : 5 } ,
275
+ ] ,
276
+ None ,
277
+ )
278
+ . await
279
+ . unwrap ( ) ;
280
+
281
+ let mut cursor = coll
282
+ . find ( None , FindOptions :: builder ( ) . batch_size ( 3 ) . build ( ) )
283
+ . await
284
+ . unwrap ( ) ;
285
+ let mut found = 0 ;
286
+ while cursor. advance ( ) . await . unwrap ( ) {
287
+ found += 1 ;
288
+ }
289
+ assert_eq ! ( found, 5 ) ;
290
+ }
You can’t perform that action at this time.
0 commit comments