@@ -5,6 +5,7 @@ use crate::{
5
5
cmap:: { CommandResponse , StreamDescription } ,
6
6
error:: ErrorKind ,
7
7
operation:: { ListDatabases , Operation } ,
8
+ options:: ListDatabasesOptions ,
8
9
selection_criteria:: ReadPreference ,
9
10
} ;
10
11
@@ -31,7 +32,7 @@ async fn build() {
31
32
async fn build_with_name_only ( ) {
32
33
let name_only = true ;
33
34
34
- let list_databases_op = ListDatabases :: new ( None , name_only) ;
35
+ let list_databases_op = ListDatabases :: new ( None , name_only, None ) ;
35
36
let list_databases_command = list_databases_op
36
37
. build ( & StreamDescription :: new_testing ( ) )
37
38
. expect ( "error on build" ) ;
@@ -52,7 +53,7 @@ async fn build_with_name_only() {
52
53
async fn build_with_filter ( ) {
53
54
let filter = doc ! { "something" : "something else" } ;
54
55
55
- let list_databases_op = ListDatabases :: new ( Some ( filter. clone ( ) ) , false ) ;
56
+ let list_databases_op = ListDatabases :: new ( Some ( filter. clone ( ) ) , false , None ) ;
56
57
let list_databases_command = list_databases_op
57
58
. build ( & StreamDescription :: new_testing ( ) )
58
59
. unwrap ( ) ;
@@ -68,6 +69,29 @@ async fn build_with_filter() {
68
69
assert_eq ! ( list_databases_command. read_pref, None ) ;
69
70
}
70
71
72
+ #[ cfg_attr( feature = "tokio-runtime" , tokio:: test) ]
73
+ #[ cfg_attr( feature = "async-std-runtime" , async_std:: test) ]
74
+ async fn build_with_options ( ) {
75
+ let options = ListDatabasesOptions :: builder ( )
76
+ . authorized_databases ( true )
77
+ . build ( ) ;
78
+
79
+ let list_databases_op = ListDatabases :: new ( None , false , Some ( options) ) ;
80
+ let list_databases_command = list_databases_op
81
+ . build ( & StreamDescription :: new_testing ( ) )
82
+ . unwrap ( ) ;
83
+ assert_eq ! (
84
+ list_databases_command. body,
85
+ doc! {
86
+ "listDatabases" : 1 ,
87
+ "nameOnly" : false ,
88
+ "authorizedDatabases" : true
89
+ }
90
+ ) ;
91
+ assert_eq ! ( list_databases_command. target_db, "admin" ) ;
92
+ assert_eq ! ( list_databases_command. read_pref, None ) ;
93
+ }
94
+
71
95
#[ cfg_attr( feature = "tokio-runtime" , tokio:: test) ]
72
96
#[ cfg_attr( feature = "async-std-runtime" , async_std:: test) ]
73
97
async fn handle_success ( ) {
0 commit comments