use super::Posted;
use serde_json::json;
#[test]
fn an_act_and_a_read_carry_the_same_envelope() {
let envelope = json!({"op": "nudge", "workspace": "home", "agent": "a"});
let act = Posted::act(envelope.clone());
let read = Posted::read(envelope.clone());
assert_eq!(act.envelope, envelope);
assert_eq!(read.envelope, envelope);
assert!(act.act);
assert!(!read.act);
}
#[test]
fn naming_no_workspace_does_not_make_a_gesture_a_read() {
let nameless: Vec<String> = crate::test_support::corpus::record()
.shapes
.into_iter()
.filter_map(|(name, signature)| {
let op = name.strip_prefix("request/")?;
let addressed = signature
.iter()
.any(|slot| slot.starts_with("/workspace") || slot.starts_with("/prepared"));
(!addressed).then(|| op.to_owned())
})
.collect();
for changes_the_world in ["create", "close", "complete", "deliver", "update", "retire"] {
assert!(
nameless.contains(&changes_the_world.to_owned()),
"{changes_the_world} is an act with no workspace slot, so the \
predicate cannot stand in for this field; nameless: {nameless:?}"
);
}
}