diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-01-22 16:31:12 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-22 22:31:12 +0100 |
commit | 69d5f136badfd7cfa9b979ff2fee7caf397098ca (patch) | |
tree | 665c6686fbf6f0732d84984f5f48557e45b4c7b6 /test_util/src | |
parent | d20c9e75d1540b1a27e721d0cf66d29ba6a2c3fb (diff) |
feat(lockfile): track JSR and npm dependencies in config file (#22004)
See overview in https://github.com/denoland/deno_lockfile/pull/13
Diffstat (limited to 'test_util/src')
-rw-r--r-- | test_util/src/fs.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test_util/src/fs.rs b/test_util/src/fs.rs index 9cfbcaaa7..17620276b 100644 --- a/test_util/src/fs.rs +++ b/test_util/src/fs.rs @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use pretty_assertions::assert_eq; use std::borrow::Cow; use std::ffi::OsStr; use std::fs; @@ -218,6 +219,7 @@ impl PathRef { } } + #[track_caller] pub fn assert_matches_file(&self, wildcard_file: impl AsRef<Path>) -> &Self { let wildcard_file = testdata_path().join(wildcard_file); println!("output path {}", wildcard_file); @@ -225,11 +227,22 @@ impl PathRef { self.assert_matches_text(&expected_text) } + #[track_caller] pub fn assert_matches_text(&self, wildcard_text: impl AsRef<str>) -> &Self { let actual = self.read_to_string(); assert_wildcard_match(&actual, wildcard_text.as_ref()); self } + + #[track_caller] + pub fn assert_matches_json(&self, expected: serde_json::Value) { + let actual_json = self.read_json_value(); + if actual_json != expected { + let actual_text = serde_json::to_string_pretty(&actual_json).unwrap(); + let expected_text = serde_json::to_string_pretty(&expected).unwrap(); + assert_eq!(actual_text, expected_text); + } + } } #[cfg(not(windows))] |