Watch
0
0
Fork
You've already forked hyperhive
0

test the wake prompt and the Messaging permission after the tool removal

This commit is contained in:
damocles 2026-11-07 17:50:30 +01:00 • committed by mara
commit 9457f49684
2 changed files with 45 additions and 0 deletions

View file

@ -110,3 +110,28 @@ pub fn build_row(args: TurnRowArgs<'_>) -> TurnStatRow {
session_id: bus.current_session_id(),
}
}
#[cfg(test)]
mod wake_prompt_tests {
use super::format_wake_prompt;
/// The prompt is the sender and body only: no `[msg #N]` tag and no
/// "N more pending, call recv" nudge, since the tools they pointed at
/// are gone.
#[test]
fn the_wake_prompt_carries_the_sender_and_body_only() {
let p = format_wake_prompt("todo", "you have todos", false, false);
assert_eq!(p, "Incoming message from `todo`:\n---\nyou have todos\n---");
assert!(!p.contains("[msg #") && !p.contains("recv"));
}
#[test]
fn a_banner_leads_the_prompt_and_redelivery_wins_over_interruption() {
let redelivered = format_wake_prompt("a", "b", true, true);
assert!(redelivered.starts_with(hive_sh4re::inbox::REDELIVERY_HINT));
let interrupted = format_wake_prompt("a", "b", false, true);
assert!(interrupted.starts_with(hive_sh4re::inbox::INTERRUPTED_HINT));
let plain = format_wake_prompt("a", "b", false, false);
assert!(plain.starts_with("Incoming message from `a`:"));
}
}

View file

@ -184,6 +184,26 @@ impl From<Permission> for &'static str {
mod tests {
use super::*;
/// Agents message each other over matrix, so no permission grants a
/// hyperhive messaging tool any more. `Messaging` stays a valid stored
/// value, and it grants nothing.
#[test]
fn messaging_is_an_accepted_value_that_grants_no_tool() {
assert!(Permission::Messaging.tools().is_empty());
assert_eq!(
serde_json::from_str::<Permission>("\"messaging\"").expect("stored value decodes"),
Permission::Messaging
);
for p in Permission::ALL {
for tool in p.tools() {
assert!(
!["send", "recv", "ack_until"].contains(tool),
"{p:?} still grants the removed tool {tool}"
);
}
}
}
/// The `as_str` spelling of every variant. `ALL` is stable-ordered, so
/// a variant added to the enum but not to `ALL` or `as_str` shows here.
#[test]