-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_env.rs
37 lines (31 loc) · 1.02 KB
/
test_env.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::env;
pub struct TestEnv {
config: String,
credentials: String,
}
impl TestEnv {
pub fn new() -> TestEnv {
TestEnv {
config: json!(
{
"read_host": env::var("DB_READ_HOST").unwrap_or("wallet".to_string()),
"write_host": env::var("DB_WRITE_HOST").unwrap_or("wallet".to_string()),
"port": env::var("DB_PORT").unwrap_or(3306.to_string()).parse::<u32>().unwrap(),
"db_name": env::var("DB_NAME").unwrap_or("wallet".to_string())
}
).to_string(),
credentials: json!(
{
"user": env::var("DB_USER").unwrap_or("wallet".to_string()),
"pass": env::var("DB_PASS").unwrap_or("wallet".to_string())
}
).to_string()
}
}
pub fn get_config(&self) -> String {
self.config.clone()
}
pub fn get_credentials(&self) -> String {
self.credentials.clone()
}
}