File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -59,13 +59,19 @@ pub(crate) fn cache_path() -> String {
59
59
60
60
pub ( crate ) fn db_connection_config ( ) -> Config {
61
61
let mut config = Config :: new ( ) ;
62
- let host = env:: var ( "RAPID_GOSSIP_SYNC_SERVER_DB_HOST" ) . unwrap_or ( "localhost" . to_string ( ) ) ;
63
- let user = env:: var ( "RAPID_GOSSIP_SYNC_SERVER_DB_USER" ) . unwrap_or ( "alice" . to_string ( ) ) ;
64
- let db = env:: var ( "RAPID_GOSSIP_SYNC_SERVER_DB_NAME" ) . unwrap_or ( "ln_graph_sync" . to_string ( ) ) ;
62
+ let env_name_prefix = if cfg ! ( test) {
63
+ "RAPID_GOSSIP_TEST_DB"
64
+ } else {
65
+ "RAPID_GOSSIP_SYNC_SERVER_DB"
66
+ } ;
67
+
68
+ let host = env:: var ( format ! ( "{}{}" , env_name_prefix, "_HOST" ) ) . unwrap_or ( "localhost" . to_string ( ) ) ;
69
+ let user = env:: var ( format ! ( "{}{}" , env_name_prefix, "_USER" ) ) . unwrap_or ( "alice" . to_string ( ) ) ;
70
+ let db = env:: var ( format ! ( "{}{}" , env_name_prefix, "_NAME" ) ) . unwrap_or ( "ln_graph_sync" . to_string ( ) ) ;
65
71
config. host ( & host) ;
66
72
config. user ( & user) ;
67
73
config. dbname ( & db) ;
68
- if let Ok ( password) = env:: var ( "RAPID_GOSSIP_SYNC_SERVER_DB_PASSWORD" ) {
74
+ if let Ok ( password) = env:: var ( format ! ( "{}{}" , env_name_prefix , "_PASSWORD" ) ) {
69
75
config. password ( & password) ;
70
76
}
71
77
config
You can’t perform that action at this time.
0 commit comments