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/http_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/http_cache.rs')
-rw-r--r-- | cli/cache/http_cache.rs | 13 |
1 files changed, 5 insertions, 8 deletions
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( |