File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -12,9 +12,12 @@ use crate::{
12
12
AggregateOptions ,
13
13
DeleteOptions ,
14
14
FindOneAndDeleteOptions ,
15
+ FindOneOptions ,
15
16
FindOptions ,
16
17
Hint ,
17
18
InsertManyOptions ,
19
+ ReadPreference ,
20
+ SelectionCriteria ,
18
21
UpdateOptions ,
19
22
} ,
20
23
results:: DeleteResult ,
@@ -720,3 +723,33 @@ async fn find_one_and_delete_hint_server_version() {
720
723
assert ! ( res. is_ok( ) ) ;
721
724
}
722
725
}
726
+
727
+ #[ cfg_attr( feature = "tokio-runtime" , tokio:: test) ]
728
+ #[ cfg_attr( feature = "async-std-runtime" , async_std:: test) ]
729
+ #[ function_name:: named]
730
+ async fn no_read_preference_to_standalone ( ) {
731
+ let client = EventClient :: new ( ) . await ;
732
+
733
+ if !client. is_standalone ( ) {
734
+ return ;
735
+ }
736
+
737
+ let options = FindOneOptions :: builder ( )
738
+ . selection_criteria ( SelectionCriteria :: ReadPreference (
739
+ ReadPreference :: SecondaryPreferred {
740
+ options : Default :: default ( ) ,
741
+ } ,
742
+ ) )
743
+ . build ( ) ;
744
+
745
+ client
746
+ . database ( function_name ! ( ) )
747
+ . collection ( function_name ! ( ) )
748
+ . find_one ( None , options)
749
+ . await
750
+ . unwrap ( ) ;
751
+
752
+ let command_started = client. get_successful_command_execution ( "find" ) . 0 ;
753
+
754
+ assert ! ( !command_started. command. contains_key( "$readPreference" ) ) ;
755
+ }
You can’t perform that action at this time.
0 commit comments