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/tsc/mod.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/tsc/mod.rs')
-rw-r--r-- | cli/tsc/mod.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/cli/tsc/mod.rs b/cli/tsc/mod.rs index 83fd84f9d..a4d6640f7 100644 --- a/cli/tsc/mod.rs +++ b/cli/tsc/mod.rs @@ -841,11 +841,11 @@ mod tests { use deno_core::OpState; use deno_graph::GraphKind; use deno_graph::ModuleGraph; - use std::fs; + use test_util::PathRef; #[derive(Debug, Default)] pub struct MockLoader { - pub fixtures: PathBuf, + pub fixtures: PathRef, } impl deno_graph::source::Loader for MockLoader { @@ -860,15 +860,13 @@ mod tests { .replace("://", "_") .replace('/', "-"); let source_path = self.fixtures.join(specifier_text); - let response = fs::read_to_string(source_path) - .map(|c| { - Some(deno_graph::source::LoadResponse::Module { - specifier: specifier.clone(), - maybe_headers: None, - content: c.into(), - }) + let response = source_path.read_to_string_if_exists().map(|c| { + Some(deno_graph::source::LoadResponse::Module { + specifier: specifier.clone(), + maybe_headers: None, + content: c.into(), }) - .map_err(|err| err.into()); + }); Box::pin(future::ready(response)) } } |