From 69d5f136badfd7cfa9b979ff2fee7caf397098ca Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 22 Jan 2024 16:31:12 -0500 Subject: feat(lockfile): track JSR and npm dependencies in config file (#22004) See overview in https://github.com/denoland/deno_lockfile/pull/13 --- test_util/src/fs.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test_util') 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) -> &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) -> &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))] -- cgit v1.2.3