@@ -22,6 +22,8 @@ mod tests {
2222 lazy_static ! {
2323 static ref HOST : String = env:: var( "HOST" ) . unwrap_or_else( |_| "127.0.0.1" . to_string( ) ) ;
2424 static ref PORT : String = env:: var( "PORT" ) . unwrap_or_else( |_| "27017" . to_string( ) ) ;
25+ static ref DATABASE : String = env:: var( "DATABASE" ) . unwrap_or_else( |_| "db_name" . to_string( ) ) ;
26+ static ref COLLECTION : String = env:: var( "COLLECTION" ) . unwrap_or_else( |_| "collection" . to_string( ) ) ;
2527 static ref CONNECTION_STRING : String =
2628 format!( "mongodb://{}:{}/" , HOST . as_str( ) , PORT . as_str( ) ) ;
2729 }
@@ -36,8 +38,8 @@ mod tests {
3638 Ok ( c) => c,
3739 Err ( e) => panic ! ( "Client Creation Failed: {}" , e) ,
3840 } ;
39-
40- let store = MongodbSessionStore :: from_client ( client, "db_name" , "collection" ) ;
41+
42+ let store = MongodbSessionStore :: from_client ( client, & DATABASE , & COLLECTION ) ;
4143 let mut rng = rand:: thread_rng ( ) ;
4244 let n2: u16 = rng. gen ( ) ;
4345 let key = format ! ( "key-{}" , n2) ;
@@ -53,7 +55,7 @@ mod tests {
5355 }
5456
5557 async fn new ( ) -> async_session:: Result {
56- let store = MongodbSessionStore :: new ( & CONNECTION_STRING , "db_name" , "collection" ) . await ?;
58+ let store = MongodbSessionStore :: new ( & CONNECTION_STRING , & DATABASE , & COLLECTION ) . await ?;
5759
5860 let mut rng = rand:: thread_rng ( ) ;
5961 let n2: u16 = rng. gen ( ) ;
@@ -70,7 +72,7 @@ mod tests {
7072 }
7173
7274 async fn with_expire ( ) -> async_session:: Result {
73- let store = MongodbSessionStore :: new ( & CONNECTION_STRING , "db_name" , "collection" ) . await ?;
75+ let store = MongodbSessionStore :: new ( & CONNECTION_STRING , & DATABASE , & COLLECTION ) . await ?;
7476
7577 store. initialize ( ) . await ?;
7678
@@ -92,7 +94,7 @@ mod tests {
9294 async fn check_expired ( ) -> async_session:: Result {
9395 use async_std:: task;
9496 use std:: time:: Duration ;
95- let store = MongodbSessionStore :: new ( & CONNECTION_STRING , "db_name" , "collection" ) . await ?;
97+ let store = MongodbSessionStore :: new ( & CONNECTION_STRING , & DATABASE , & COLLECTION ) . await ?;
9698
9799 store. initialize ( ) . await ?;
98100
0 commit comments