diff options
Diffstat (limited to 'cli/cache')
-rw-r--r-- | cli/cache/disk_cache.rs | 13 | ||||
-rw-r--r-- | cli/cache/emit.rs | 2 | ||||
-rw-r--r-- | cli/cache/http_cache.rs | 13 |
3 files changed, 12 insertions, 16 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:"); diff --git a/cli/cache/emit.rs b/cli/cache/emit.rs index dd7b9e662..f0e94d209 100644 --- a/cli/cache/emit.rs +++ b/cli/cache/emit.rs @@ -159,7 +159,7 @@ mod test { #[test] pub fn emit_cache_general_use() { let temp_dir = TempDir::new(); - let disk_cache = DiskCache::new(temp_dir.path()); + let disk_cache = DiskCache::new(temp_dir.path().as_path()); let cache = EmitCache { disk_cache: disk_cache.clone(), cli_version: "1.0.0", diff --git a/cli/cache/http_cache.rs b/cli/cache/http_cache.rs index b10c59756..e98f4bad7 100644 --- a/cli/cache/http_cache.rs +++ b/cli/cache/http_cache.rs @@ -111,11 +111,9 @@ impl HttpCache { /// Returns a new instance. /// /// `location` must be an absolute path. - pub fn new(location: &Path) -> Self { + pub fn new(location: PathBuf) -> Self { assert!(location.is_absolute()); - Self { - location: location.to_owned(), - } + Self { location } } /// Ensures the location of the cache. @@ -192,8 +190,7 @@ mod tests { #[test] fn test_create_cache() { let dir = TempDir::new(); - let mut cache_path = dir.path().to_owned(); - cache_path.push("foobar"); + let cache_path = dir.path().join("foobar"); // HttpCache should be created lazily on first use: // when zipping up a local project with no external dependencies // "$DENO_DIR/deps" is empty. When unzipping such project @@ -203,7 +200,7 @@ mod tests { // doesn't make sense to return error in such specific scenarios. // For more details check issue: // https://github.com/denoland/deno/issues/5688 - let cache = HttpCache::new(&cache_path); + let cache = HttpCache::new(cache_path.to_path_buf()); assert!(!cache.location.exists()); cache .set( @@ -219,7 +216,7 @@ mod tests { #[test] fn test_get_set() { let dir = TempDir::new(); - let cache = HttpCache::new(dir.path()); + let cache = HttpCache::new(dir.path().to_path_buf()); let url = Url::parse("https://deno.land/x/welcome.ts").unwrap(); let mut headers = HashMap::new(); headers.insert( |