karma: karmaweb command + web-board link on top lists, via configurable karma_url
All checks were successful
ci / check (push) Successful in 47s
All checks were successful
ci / check (push) Successful in 47s
This commit is contained in:
parent
739fc8ad94
commit
7f6327270b
6 changed files with 92 additions and 7 deletions
|
|
@ -259,3 +259,38 @@ fn replies_in_spanish_for_es_locale() {
|
|||
let _ = std::fs::remove_file(&path);
|
||||
let _ = std::fs::remove_file(&log);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn karmaweb_command_and_leaderboard_suffix() {
|
||||
let path = std::env::temp_dir().join("rubot-test-karma-web.json");
|
||||
let log = std::env::temp_dir().join("rubot-test-karma-web.events.jsonl");
|
||||
let _ = std::fs::remove_file(&path);
|
||||
let _ = std::fs::remove_file(&log);
|
||||
let mut k =
|
||||
Karma::with_path(path.clone()).with_url(Some("https://karma.devtronic.pro/".to_string()));
|
||||
// dedicated command returns the link
|
||||
let w = reply_of(&mut k, "karmaweb", &[]);
|
||||
assert!(w.contains("https://karma.devtronic.pro/"), "{w}");
|
||||
// link is appended to the aggregate list...
|
||||
k.on_message(&chat("a", "rust++ python++"));
|
||||
let top = reply_of(&mut k, "karma", &[]);
|
||||
assert!(top.starts_with("karma top:"), "{top}");
|
||||
assert!(
|
||||
top.contains("full board: https://karma.devtronic.pro/"),
|
||||
"{top}"
|
||||
);
|
||||
// ...but not to a single-thing lookup (kept clean)
|
||||
let one = reply_of(&mut k, "karma", &["rust"]);
|
||||
assert!(!one.contains("http"), "{one}");
|
||||
let _ = std::fs::remove_file(&path);
|
||||
let _ = std::fs::remove_file(&log);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn karmaweb_without_url_is_graceful() {
|
||||
let path = std::env::temp_dir().join("rubot-test-karma-nourl.json");
|
||||
let _ = std::fs::remove_file(&path);
|
||||
let mut k = Karma::with_path(path.clone());
|
||||
assert!(reply_of(&mut k, "karmaweb", &[]).contains("no web board configured"));
|
||||
let _ = std::fs::remove_file(&path);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue