diff options
author | Yusuke Sakurai <kerokerokerop@gmail.com> | 2020-04-06 23:08:53 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-06 10:08:53 -0400 |
commit | b9e5e4c7ec9e044f014f2b8a5cfd469f92091ec2 (patch) | |
tree | 9c33ecc8b8bbc03e61fd8c0fb226b87ff722729d /cli/disk_cache.rs | |
parent | 1e478d73e3e031c78a170b195021aeb22fd45feb (diff) |
fix: test_create_cache_if_dir_not_exit (#4636)
This test doesn't remove created directory after test. It will fail on next run.
Diffstat (limited to 'cli/disk_cache.rs')
-rw-r--r-- | cli/disk_cache.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/cli/disk_cache.rs b/cli/disk_cache.rs index 51c9d8612..e458bb135 100644 --- a/cli/disk_cache.rs +++ b/cli/disk_cache.rs @@ -146,11 +146,10 @@ mod tests { #[test] fn test_create_cache_if_dir_not_exits() { - let cache_location = if cfg!(target_os = "windows") { - PathBuf::from(r"C:\deno_dir\foo") - } else { - PathBuf::from("~/deno_dir/foo") - }; + let temp_dir = TempDir::new().unwrap(); + let mut cache_location = temp_dir.path().to_owned(); + assert!(fs::remove_dir(&cache_location).is_ok()); + cache_location.push("foo"); assert_eq!(cache_location.is_dir(), false); DiskCache::new(&cache_location); assert_eq!(cache_location.is_dir(), true); |