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::{
1212 AggregateOptions ,
1313 DeleteOptions ,
1414 FindOneAndDeleteOptions ,
15+ FindOneOptions ,
1516 FindOptions ,
1617 Hint ,
1718 InsertManyOptions ,
19+ ReadPreference ,
20+ SelectionCriteria ,
1821 UpdateOptions ,
1922 } ,
2023 results:: DeleteResult ,
@@ -720,3 +723,33 @@ async fn find_one_and_delete_hint_server_version() {
720723 assert ! ( res. is_ok( ) ) ;
721724 }
722725}
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