fix: reset env var post testing
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful

This commit is contained in:
Aravinth Manivannan 2024-07-14 22:11:42 +05:30
parent 53239dd55e
commit 452da98cbe
Signed by: realaravinth
GPG key ID: F8F50389936984FF
2 changed files with 4 additions and 1 deletions

View file

@ -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();
}
}

View file

@ -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);
}
};