fix: reset env var post testing
This commit is contained in:
parent
53239dd55e
commit
452da98cbe
2 changed files with 4 additions and 1 deletions
|
@ -39,7 +39,6 @@ pub struct PostgresDatabase;
|
|||
#[async_trait::async_trait]
|
||||
impl super::create_database::CreateDatabase for PostgresDatabase {
|
||||
async fn create_database(&self, url: &url::Url) {
|
||||
println!("Trying to connect to: {}", url.as_str());
|
||||
sqlx::Postgres::create_database(url.as_str()).await.unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,6 +130,7 @@ pub mod tests {
|
|||
macro_rules! env_helper {
|
||||
($init_settings:ident, $env:expr, $val:expr, $val_typed:expr, $($param:ident).+) => {
|
||||
println!("Setting env var {} to {} for test", $env, $val);
|
||||
let current = env::var($env);
|
||||
env::set_var($env, $val);
|
||||
{
|
||||
let new_settings = $crate::settings::Settings::new().unwrap();
|
||||
|
@ -137,6 +138,9 @@ pub mod tests {
|
|||
assert_ne!(new_settings.$($param).+, $init_settings.$($param).+);
|
||||
}
|
||||
env::remove_var($env);
|
||||
if let Ok(current) = current {
|
||||
env::set_var($env, current);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue