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/lsp/registries.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/lsp/registries.rs')
-rw-r--r-- | cli/lsp/registries.rs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/cli/lsp/registries.rs b/cli/lsp/registries.rs index b2f9bee2c..f683fa588 100644 --- a/cli/lsp/registries.rs +++ b/cli/lsp/registries.rs @@ -34,7 +34,7 @@ use deno_runtime::permissions::PermissionsContainer; use log::error; use once_cell::sync::Lazy; use std::collections::HashMap; -use std::path::Path; +use std::path::PathBuf; use std::sync::Arc; use tower_lsp::lsp_types as lsp; @@ -427,12 +427,12 @@ impl Default for ModuleRegistry { let dir = DenoDir::new(None).unwrap(); let location = dir.registries_folder_path(); let http_client = Arc::new(HttpClient::new(None, None)); - Self::new(&location, http_client) + Self::new(location, http_client) } } impl ModuleRegistry { - pub fn new(location: &Path, http_client: Arc<HttpClient>) -> Self { + pub fn new(location: PathBuf, http_client: Arc<HttpClient>) -> Self { let http_cache = HttpCache::new(location); let mut file_fetcher = FileFetcher::new( http_cache, @@ -1247,9 +1247,9 @@ mod tests { async fn test_registry_completions_origin_match() { let _g = test_util::http_server(); let temp_dir = TempDir::new(); - let location = temp_dir.path().join("registries"); + let location = temp_dir.path().join("registries").to_path_buf(); let mut module_registry = - ModuleRegistry::new(&location, Arc::new(HttpClient::new(None, None))); + ModuleRegistry::new(location, Arc::new(HttpClient::new(None, None))); module_registry .enable("http://localhost:4545/") .await @@ -1308,9 +1308,9 @@ mod tests { async fn test_registry_completions() { let _g = test_util::http_server(); let temp_dir = TempDir::new(); - let location = temp_dir.path().join("registries"); + let location = temp_dir.path().join("registries").to_path_buf(); let mut module_registry = - ModuleRegistry::new(&location, Arc::new(HttpClient::new(None, None))); + ModuleRegistry::new(location, Arc::new(HttpClient::new(None, None))); module_registry .enable("http://localhost:4545/") .await @@ -1531,9 +1531,9 @@ mod tests { async fn test_registry_completions_key_first() { let _g = test_util::http_server(); let temp_dir = TempDir::new(); - let location = temp_dir.path().join("registries"); + let location = temp_dir.path().join("registries").to_path_buf(); let mut module_registry = - ModuleRegistry::new(&location, Arc::new(HttpClient::new(None, None))); + ModuleRegistry::new(location, Arc::new(HttpClient::new(None, None))); module_registry .enable_custom("http://localhost:4545/lsp/registries/deno-import-intellisense-key-first.json") .await @@ -1601,9 +1601,9 @@ mod tests { async fn test_registry_completions_complex() { let _g = test_util::http_server(); let temp_dir = TempDir::new(); - let location = temp_dir.path().join("registries"); + let location = temp_dir.path().join("registries").to_path_buf(); let mut module_registry = - ModuleRegistry::new(&location, Arc::new(HttpClient::new(None, None))); + ModuleRegistry::new(location, Arc::new(HttpClient::new(None, None))); module_registry .enable_custom("http://localhost:4545/lsp/registries/deno-import-intellisense-complex.json") .await @@ -1652,9 +1652,9 @@ mod tests { async fn test_check_origin_supported() { let _g = test_util::http_server(); let temp_dir = TempDir::new(); - let location = temp_dir.path().join("registries"); + let location = temp_dir.path().join("registries").to_path_buf(); let module_registry = - ModuleRegistry::new(&location, Arc::new(HttpClient::new(None, None))); + ModuleRegistry::new(location, Arc::new(HttpClient::new(None, None))); let result = module_registry.check_origin("http://localhost:4545").await; assert!(result.is_ok()); } @@ -1663,9 +1663,9 @@ mod tests { async fn test_check_origin_not_supported() { let _g = test_util::http_server(); let temp_dir = TempDir::new(); - let location = temp_dir.path().join("registries"); + let location = temp_dir.path().join("registries").to_path_buf(); let module_registry = - ModuleRegistry::new(&location, Arc::new(HttpClient::new(None, None))); + ModuleRegistry::new(location, Arc::new(HttpClient::new(None, None))); let result = module_registry.check_origin("https://example.com").await; assert!(result.is_err()); let err = result.unwrap_err().to_string(); |