Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guenhter committed Aug 18, 2024
1 parent db8eaac commit f603b5f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions temp_env_vars_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mod tests {

{
let _env_scope = TestEnvScope::new();
std::env::set_var("FOO", "BAR");
std::env::set_var("FOO", "BAR1");
}

let after: HashMap<String, String> = std::env::vars().collect();
Expand All @@ -76,7 +76,7 @@ mod tests {
#[test]
#[serial]
fn test_changed_vars_are_reset() {
std::env::set_var("FOO", "BAR");
std::env::set_var("FOO", "BAR2");
let original: HashMap<String, String> = std::env::vars().collect();

{
Expand All @@ -85,14 +85,14 @@ mod tests {
}

let after: HashMap<String, String> = std::env::vars().collect();
assert_that!(std::env::var("FOO")).has_ok("BAR".to_string());
assert_that!(std::env::var("FOO")).has_ok("BAR2".to_string());
assert_that!(after).is_equal_to(original);
}

#[test]
#[serial]
fn test_env_vars_are_restored() {
std::env::set_var("FOO", "BAR");
std::env::set_var("FOO", "BAR3");
let original: HashMap<String, String> = std::env::vars().collect();

{
Expand All @@ -101,20 +101,20 @@ mod tests {
}

let after: HashMap<String, String> = std::env::vars().collect();
assert_that!(std::env::var("FOO")).has_ok("BAR".to_string());
assert_that!(std::env::var("FOO")).has_ok("BAR3".to_string());
assert_that!(after).is_equal_to(original);
}

#[test]
#[serial]
fn test_two_scopes_active_at_same_time() {
assert_that!(std::env::var("FOO")).is_err();
std::env::remove_var("FOO");

{
let _env_scope_1 = TestEnvScope::new();
let _env_scope_2 = TestEnvScope::new();

std::env::set_var("FOO", "BAR");
std::env::set_var("FOO", "BAR4");
assert_that!(std::env::var("FOO")).is_ok();
}

Expand All @@ -124,20 +124,20 @@ mod tests {
#[test]
#[serial]
fn test_sequential_test_scopes() {
assert_that!(std::env::var("FOO")).is_err();
std::env::remove_var("FOO");

{
let _env_scope = TestEnvScope::new();

std::env::set_var("FOO", "BAR");
std::env::set_var("FOO", "BAR5");
assert_that!(std::env::var("FOO")).is_ok();
}
assert_that!(std::env::var("FOO")).is_err();

{
let _env_scope = TestEnvScope::new();

std::env::set_var("FOO", "BAR");
std::env::set_var("FOO", "BAR6");
assert_that!(std::env::var("FOO")).is_ok();
}
assert_that!(std::env::var("FOO")).is_err();
Expand Down

0 comments on commit f603b5f

Please sign in to comment.