Friendlier weather output
This commit is contained in:
parent
7fefcbac46
commit
5e0ca7232a
2 changed files with 39 additions and 12 deletions
|
|
@ -2,7 +2,7 @@ use std::collections::BTreeMap;
|
|||
use std::path::PathBuf;
|
||||
|
||||
use rustbot::bot::module::{Action, Command, Module};
|
||||
use rustbot::bot::modules::weather::{parse_db, to_json, Weather};
|
||||
use rustbot::bot::modules::weather::{format_weather, parse_db, to_json, Weather};
|
||||
|
||||
fn cmd<'a>(sender: &'a str, name: &'a str, args: &'a [&'a str]) -> Command<'a> {
|
||||
Command { sender, reply_to: "#chan", name, args, prefix: ">", network: "test" }
|
||||
|
|
@ -65,3 +65,19 @@ fn w_without_saved_location_hints_to_add() {
|
|||
let r = reply(&w.on_command(&cmd("nobody", "w", &[]))).to_string();
|
||||
assert!(r.contains("add"), "reply: {r:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_weather_builds_friendly_line() {
|
||||
let out = format_weather("73700|☀️ |Sunny|+23°C|+18°C|↘8km/h|45%", "73700");
|
||||
assert!(out.contains("☀️"), "{out}");
|
||||
assert!(out.contains("73700: Sunny"), "{out}");
|
||||
assert!(out.contains("23°C") && !out.contains("+23"), "{out}");
|
||||
assert!(out.contains("feels like 18°C"), "{out}");
|
||||
assert!(out.contains("45%"), "{out}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_weather_friendly_not_found() {
|
||||
let out = format_weather("location not found: upstream error", "zzz");
|
||||
assert!(out.contains("couldn't find 'zzz'"), "{out}");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue