From 457f9d71e618758968d1dacbf7e711b779c9240b Mon Sep 17 00:00:00 2001 From: Mahesh Asolkar Date: Sun, 27 Jul 2025 21:39:08 -0700 Subject: [PATCH] Weather module unit tests passing --- src/bar_modules/bar_module_weather.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/bar_modules/bar_module_weather.rs b/src/bar_modules/bar_module_weather.rs index e469a83..6bc6efc 100644 --- a/src/bar_modules/bar_module_weather.rs +++ b/src/bar_modules/bar_module_weather.rs @@ -515,15 +515,27 @@ mod tests { "features": [{ "properties": { "temperature": { - "value": "20.5" + "value": 20.5 } } }] }); - //println!("{:#?}", module.weather_info); - let temp = module.get_current_temperature().unwrap(); - assert_eq!(temp, 20.5); + // println!("{:#?}", module.weather_info); + let result = module.get_current_temperature(); + // println!("{:#?}", result); + match result { + Ok(20.5) => { + // This is fine - we expect 20.5 for valid weather_info + assert_eq!(module.weather_info["features"][0]["properties"]["temperature"]["value"], 20.5); + }, + Err(WeatherError::ApiResponseStrErr(_)) => { + assert!(false, "Expected valid temperature but got ApiResponseStrErr"); + }, + other => { + panic!("Unexpected result: {:?}", other); + } + } } #[test] @@ -539,9 +551,10 @@ mod tests { } }] }); - - assert_eq!(module.get_icon(), "☁️"); - assert_eq!(module.get_icon(), "☁"); + let icon = module.get_icon(); + // println!("Extracted icon: {}", icon); + // Check if the icon is correctly extracted + assert_eq!(icon, "☁️"); } #[test]