Weather module unit tests passing
This commit is contained in:
@@ -515,15 +515,27 @@ mod tests {
|
|||||||
"features": [{
|
"features": [{
|
||||||
"properties": {
|
"properties": {
|
||||||
"temperature": {
|
"temperature": {
|
||||||
"value": "20.5"
|
"value": 20.5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
//println!("{:#?}", module.weather_info);
|
// println!("{:#?}", module.weather_info);
|
||||||
let temp = module.get_current_temperature().unwrap();
|
let result = module.get_current_temperature();
|
||||||
assert_eq!(temp, 20.5);
|
// 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]
|
#[test]
|
||||||
@@ -539,9 +551,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
let icon = module.get_icon();
|
||||||
assert_eq!(module.get_icon(), "☁️");
|
// println!("Extracted icon: {}", icon);
|
||||||
assert_eq!(module.get_icon(), "☁");
|
// Check if the icon is correctly extracted
|
||||||
|
assert_eq!(icon, "☁️");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Reference in New Issue
Block a user