@@ -10,14 +10,16 @@ mod tests {
1010 lazy_static ! {
1111 static ref HOST : String = env:: var( "HOST" ) . unwrap_or_else( |_| "127.0.0.1" . to_string( ) ) ;
1212 static ref PORT : String = env:: var( "PORT" ) . unwrap_or_else( |_| "27017" . to_string( ) ) ;
13+ static ref DATABASE : String = env:: var( "DATABASE" ) . unwrap_or_else( |_| "db_name" . to_string( ) ) ;
14+ static ref COLLECTION : String = env:: var( "COLLECTION" ) . unwrap_or_else( |_| "collection" . to_string( ) ) ;
1315 static ref CONNECTION_STRING : String =
1416 format!( "mongodb://{}:{}/" , HOST . as_str( ) , PORT . as_str( ) ) ;
1517 }
1618
1719 #[ test]
1820 fn test_from_client ( ) -> async_session:: Result {
1921 async_std:: task:: block_on ( async {
20- let client_options = match ClientOptions :: parse ( & CONNECTION_STRING ) . await {
22+ let client_options = match ClientOptions :: parse ( & * CONNECTION_STRING ) . await {
2123 Ok ( c) => c,
2224 Err ( e) => panic ! ( "Client Options Failed: {}" , e) ,
2325 } ;
@@ -26,8 +28,8 @@ mod tests {
2628 Ok ( c) => c,
2729 Err ( e) => panic ! ( "Client Creation Failed: {}" , e) ,
2830 } ;
29-
30- let store = MongodbSessionStore :: from_client ( client, "db_name" , "collection" ) ;
31+
32+ let store = MongodbSessionStore :: from_client ( client, & DATABASE , & COLLECTION ) ;
3133 let mut rng = rand:: thread_rng ( ) ;
3234 let n2: u16 = rng. gen ( ) ;
3335 let key = format ! ( "key-{}" , n2) ;
@@ -47,7 +49,7 @@ mod tests {
4749 fn test_new ( ) -> async_session:: Result {
4850 async_std:: task:: block_on ( async {
4951 let store =
50- MongodbSessionStore :: new ( & CONNECTION_STRING , "db_name" , "collection" ) . await ?;
52+ MongodbSessionStore :: new ( & CONNECTION_STRING , & DATABASE , & COLLECTION ) . await ?;
5153
5254 let mut rng = rand:: thread_rng ( ) ;
5355 let n2: u16 = rng. gen ( ) ;
@@ -68,7 +70,7 @@ mod tests {
6870 fn test_with_expire ( ) -> async_session:: Result {
6971 async_std:: task:: block_on ( async {
7072 let store =
71- MongodbSessionStore :: new ( & CONNECTION_STRING , "db_name" , "collection" ) . await ?;
73+ MongodbSessionStore :: new ( & CONNECTION_STRING , & DATABASE , & COLLECTION ) . await ?;
7274
7375 store. initialize ( ) . await ?;
7476
@@ -94,7 +96,7 @@ mod tests {
9496 use std:: time:: Duration ;
9597 async_std:: task:: block_on ( async {
9698 let store =
97- MongodbSessionStore :: new ( & CONNECTION_STRING , "db_name" , "collection" ) . await ?;
99+ MongodbSessionStore :: new ( & CONNECTION_STRING , & DATABASE , & COLLECTION ) . await ?;
98100
99101 store. initialize ( ) . await ?;
100102
0 commit comments