Skip to content

Commit

Permalink
test: add a test case for override_temp_dir (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
surban authored and Stebalien committed Jul 29, 2024
1 parent ce8b147 commit 9825fff
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/env.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![deny(rust_2018_idioms)]

use std::path::Path;

#[test]
fn test_override_temp_dir() {
assert_eq!(tempfile::env::temp_dir(), std::env::temp_dir());

let new_tmp = Path::new("/tmp/override");
tempfile::env::override_temp_dir(&new_tmp).unwrap();
assert_eq!(tempfile::env::temp_dir(), new_tmp);

let new_tmp2 = Path::new("/tmp/override2");
tempfile::env::override_temp_dir(new_tmp2).expect_err("override should only be possible once");
}

0 comments on commit 9825fff

Please sign in to comment.