diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-06-10 11:09:45 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-10 11:09:45 -0400 |
commit | 7f15126f23d97f20a4fb33e43136cd4d13825863 (patch) | |
tree | 85d77389969b31999680059e65954a9fa863758e /cli/cache/disk_cache.rs | |
parent | f3326eebd6af2aaca1543e8cb543a7b16762bc96 (diff) |
chore(tests): test_util - Add `PathRef` (#19450)
This adds a new `PathRef` struct to test_util for making it easier to
work with paths in test code. I'm going to expand on this more in the
future.
Diffstat (limited to 'cli/cache/disk_cache.rs')
-rw-r--r-- | cli/cache/disk_cache.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/cli/cache/disk_cache.rs b/cli/cache/disk_cache.rs index 042064463..456b59912 100644 --- a/cli/cache/disk_cache.rs +++ b/cli/cache/disk_cache.rs @@ -166,9 +166,8 @@ mod tests { #[test] fn test_create_cache_if_dir_exits() { let cache_location = TempDir::new(); - let mut cache_path = cache_location.path().to_owned(); - cache_path.push("foo"); - let cache = DiskCache::new(&cache_path); + let cache_path = cache_location.path().join("foo"); + let cache = DiskCache::new(cache_path.as_path()); cache .ensure_dir_exists(&cache.location) .expect("Testing expect:"); @@ -178,11 +177,11 @@ mod tests { #[test] fn test_create_cache_if_dir_not_exits() { let temp_dir = TempDir::new(); - let mut cache_location = temp_dir.path().to_owned(); - assert!(fs::remove_dir(&cache_location).is_ok()); - cache_location.push("foo"); + let cache_location = temp_dir.path(); + cache_location.remove_dir_all(); + let cache_location = cache_location.join("foo"); assert!(!cache_location.is_dir()); - let cache = DiskCache::new(&cache_location); + let cache = DiskCache::new(cache_location.as_path()); cache .ensure_dir_exists(&cache.location) .expect("Testing expect:"); |