From 0245c7ddbf8b98c68b957b4848bdd3c6ac5ed59f Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Mon, 14 Oct 2024 21:10:27 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20update=20tests=20for=20day=20that?= =?UTF-8?q?=20were=20using=20system=20local=20time?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the recently added test were bound to fail as the day changed --- src/modules/display/day.rs | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/modules/display/day.rs b/src/modules/display/day.rs index 8c83fd2..45b6546 100644 --- a/src/modules/display/day.rs +++ b/src/modules/display/day.rs @@ -143,6 +143,7 @@ mod tests { use crate::modules::display::utils::common_tests::{ init_test_params, init_test_product, TEST_PARAMS, TEST_PRODUCT, }; + use chrono::{Datelike, Weekday}; use strip_ansi_escapes; #[test] @@ -150,34 +151,40 @@ mod tests { let test_product = TEST_PRODUCT.get_or_init(init_test_product); let test_params = TEST_PARAMS.get_or_init(init_test_params); + // TODO: store parsed date as params value to reduce redudancy. + let test_date = + NaiveDate::parse_from_str(&test_product.weather.current_weather.time, "%Y-%m-%dT%H:%M").unwrap(); + assert_eq!(test_date.weekday(), Weekday::Mon); + let want = "\ ╭────────────────────────────────────────────────────────────────────────╮ │ Berlin, Germany │ ├────────────────────────────────────────────────────────────────────────┤ -│  Slight Rain, 20.3/12.0°C ❲88󰖎❳  Mon, 14 Oct │ -│ Feels like 21.1/11.4°C  07:20  18:26 │ +│  Slight Rain Showers, 15.1/6.8°C ❲25󰖎❳  Mon, 7 Oct │ +│ Feels like 14.5/4.3°C  07:18  18:29 │ │ │ │ Hourly Forecast │ -├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤ -│ ₁₃ ₁₂ ₁₂ ₁₃ ₁₈ ₂₀ ₁₉ ₁₇  │ +│ 15.1/6.8°C ❲25󰖎❳ │ +├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╤┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤ +│ ₉ ₈ ₇ ₇ ₁₂ ₁₅ ₁₄ ₁₄  │ │ │ -│ 🭺🭹🭸🭷🭷🭶🭶🭶▔▔▔▔▔▔▔🭶🭶🭶🭷🭷🭹🭹🭹🭹🭺🭺🭺🭻🭻🭻▁▁▁ │ -│🭻🭻🭻▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁🭻🭻🭻🭺🭹🭹🭸🭷🭷🭶▔▔▔ ▔▔▔│ -│ ₀ ₂₀ ₈₈ ₁₃ ₃ ₀ ₁₃ ₇₀ 󰖎 │ -├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤ +│ 🭺🭹🭸🭷🭷🭶🭶🭶▔▔▔▔🭶🭶🭶🭶🭶🭶🭷🭷🭷🭷🭷🭷🭸🭸🭸🭸🭸🭸🭹🭹🭹🭹🭹🭹│ +│🭹🭹🭹🭺🭺🭺🭺🭺🭺🭻🭻🭻🭻🭻🭻▁▁▁▁▁▁▁▁▁▁▁▁🭻🭻🭺🭹🭸🭷🭶▔▔ │ +│ ₀ ₀ ₀ ₀ ₀ ₂₅ ₀ ₀ 󰖎 │ +├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╧┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤ │⁰⁰˙⁰⁰ ⁰³˙⁰⁰ ⁰⁶˙⁰⁰ ⁰⁹˙⁰⁰ ¹²˙⁰⁰ ¹⁵˙⁰⁰ ¹⁸˙⁰⁰ ²¹˙⁰⁰ │ ╰────────────────────────────────────────────────────────────────────────╯"; - // FIXME: index - let lines = prep(test_product, test_params, 1).unwrap(); + let lines = prep(test_product, test_params, 0).unwrap(); let have = strip_ansi_escapes::strip_str(lines.join("\n")); + println!("{have}"); assert_eq!(want, have); let want = "\ ╭────────────────────────────────────────────────────────────────────────╮ │ Berlin, Germany │ ├────────────────────────────────────────────────────────────────────────┤ -│  Moderate Rain, 17.9/13.7°C ❲98󰖎❳  Tue, 15 Oct │ +│  Moderate Rain, 17.9/13.7°C ❲98󰖎❳  Wed, 9 Oct │ │ Feels like 17.4/13.7°C  07:22  18:24 │ │ │ │ Hourly Forecast │