mirror of
https://github.com/SkyfallWasTaken/arcade-monitor.git
synced 2024-11-25 18:33:48 +00:00
Add fulfillment description
This commit is contained in:
parent
c624880519
commit
73cc31d44f
1 changed files with 35 additions and 2 deletions
|
@ -16,6 +16,10 @@ pub fn format_item_diff(old: &ShopItem, new: &ShopItem) -> Option<String> {
|
||||||
result.push(format!("*Name:* {}", new.full_name));
|
result.push(format!("*Name:* {}", new.full_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if old.price != new.price {
|
||||||
|
result.push(format!("*Price:* {} → {}", old.price, new.price));
|
||||||
|
}
|
||||||
|
|
||||||
if old.description != new.description {
|
if old.description != new.description {
|
||||||
result.push(format!(
|
result.push(format!(
|
||||||
"*Description:* {} → {}",
|
"*Description:* {} → {}",
|
||||||
|
@ -24,8 +28,12 @@ pub fn format_item_diff(old: &ShopItem, new: &ShopItem) -> Option<String> {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if old.price != new.price {
|
if old.fulfillment_description != new.fulfillment_description {
|
||||||
result.push(format!("*Price:* {} → {}", old.price, new.price));
|
result.push(format!(
|
||||||
|
"*Fulfillment info:* {} → {}",
|
||||||
|
old.description.as_ref().unwrap_or(&"_not set_".into()),
|
||||||
|
new.description.as_ref().unwrap_or(&"_not set_".into())
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if old.stock != new.stock {
|
if old.stock != new.stock {
|
||||||
|
@ -226,6 +234,31 @@ mod diff_tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_fulfillment_info() {
|
||||||
|
let old = ShopItem {
|
||||||
|
full_name: "Test".into(),
|
||||||
|
fulfillment_description: Some("Lorem ipsum".into()),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let new = ShopItem {
|
||||||
|
full_name: "Test".into(),
|
||||||
|
fulfillment_description: Some("Dolor sit amet".into()),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
format_item_diff(&old, &new),
|
||||||
|
Some(
|
||||||
|
indoc! {"
|
||||||
|
*Name:* Test
|
||||||
|
*Fulfillment info:* Lorem ipsum → Dolor sit amet"}
|
||||||
|
.into()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn equal_items_no_diff() {
|
fn equal_items_no_diff() {
|
||||||
let item = ShopItem {
|
let item = ShopItem {
|
||||||
|
|
Loading…
Reference in a new issue