From 01ea8485e8e476c85e1666d2af3d12e02195e746 Mon Sep 17 00:00:00 2001 From: SkyfallWasTaken Date: Mon, 1 Jul 2024 18:20:32 +0100 Subject: [PATCH] Clean up test --- Cargo.lock | 7 +++++++ Cargo.toml | 3 +++ src/diff.rs | 9 ++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index f25563f..603f754 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,6 +36,7 @@ version = "0.1.0" dependencies = [ "console_error_panic_hook", "getrandom", + "indoc", "scraper", "serde", "serde_json", @@ -355,6 +356,12 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "indoc" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" + [[package]] name = "itoa" version = "1.0.11" diff --git a/Cargo.toml b/Cargo.toml index d7f4132..bdf539d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,3 +21,6 @@ scraper = "0.19.0" # We don't use getrandom, but we enable the "js" feature to enable # WebAssembly support. getrandom = { version = "0.2", features = ["js"] } + +[dev-dependencies] +indoc = "2.0.5" diff --git a/src/diff.rs b/src/diff.rs index dcfba7f..66fc3d2 100644 --- a/src/diff.rs +++ b/src/diff.rs @@ -45,6 +45,7 @@ pub fn diff_items(old: ShopItem, new: ShopItem) -> Option { #[cfg(test)] mod test { use super::*; + use indoc::indoc; #[test] fn price_diff() { @@ -62,7 +63,13 @@ mod test { assert_eq!( diff_items(old, new), - Some("*Item updated*\n*Name:* Test\n*Price:* 1 → 2".into()) + Some( + indoc! {" + *Item updated* + *Name:* Test + *Price:* 1 → 2"} + .into() + ) ); } }