-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(starknet_sequencer_node): fix the conditional print on config t…
…ests
- Loading branch information
1 parent
0421768
commit 084a448
Showing
6 changed files
with
45 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//! Utils for config test. | ||
use assert_json_diff::{assert_json_matches_no_panic, CompareMode, Config}; | ||
use serde::Serialize; | ||
|
||
/// Compares two JSON values for an exact match without panicking. | ||
/// See [`assert_json_matches_no_panic`] | ||
pub fn assert_json_exact_matches_no_panic<Lhs, Rhs>(lhs: &Lhs, rhs: &Rhs) -> Result<(), String> | ||
where | ||
Lhs: Serialize, | ||
Rhs: Serialize, | ||
{ | ||
assert_json_matches_no_panic(lhs, rhs, Config::new(CompareMode::Strict)) | ||
} | ||
|
||
#[macro_export] | ||
/// Compare two JSON values for an exact match. | ||
/// | ||
/// Extends the functionality of [`assert_json_diff::assert_json_eq`] by also adding a customizable | ||
/// error message print. | ||
macro_rules! assert_json_eq { | ||
($lhs:expr, $rhs:expr, $error_message:expr $(,)?) => {{ | ||
if let Err(error) = | ||
$crate::test_utils::assert_json_eq::assert_json_exact_matches_no_panic(&$lhs, &$rhs) | ||
{ | ||
let printed_error = format!("\n\n{}\n{}\n\n", $error_message, error); | ||
panic!("{}", printed_error); | ||
} | ||
}}; | ||
|
||
($lhs:expr, $rhs:expr $(,)?) => {{ | ||
if let Err(error) = $crate::test_utils::assert_json_exact_matches_no_panic(&$lhs, &$rhs) { | ||
let printed_error = format!("\n\n{}\n\n", error); | ||
panic!("{}", printed_error); | ||
} | ||
}}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters