Weather module unit tests passing
This commit is contained in:
@@ -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]
|
||||
|
Reference in New Issue
Block a user