use serde_json::json;
use super::{PROPOSAL, PROPOSALS, VERDICTS, proposal, proposals};
#[test]
fn a_bare_listing_carries_no_id_field() {
let gesture = proposals("ws".to_owned(), None);
assert_eq!(gesture, json!({"op": "proposals", "workspace": "ws"}));
assert_eq!(gesture.get("id"), None);
assert_eq!(PROPOSALS.usage(), "lernie proposals <workspace>");
}
#[test]
fn naming_a_proposal_rides_the_same_op_one_depth_down() {
assert_eq!(
proposals("ws".to_owned(), Some("20260906T090000Z-r001".to_owned())),
json!({"op": "proposals", "workspace": "ws", "id": "20260906T090000Z-r001"})
);
}
#[test]
fn the_settle_requires_the_proposal_and_the_verdict() {
assert_eq!(
proposal(
"ws".to_owned(),
"20260906T090000Z-r001".to_owned(),
"accept".to_owned()
),
json!({"op": "proposal", "workspace": "ws", "id": "20260906T090000Z-r001",
"verdict": "accept"})
);
assert_eq!(
PROPOSAL.usage(),
"lernie proposal <workspace> <id> <verdict>"
);
let short = PROPOSAL.envelope(vec!["ws".to_owned(), "r001".to_owned()]);
assert!(
short.is_err_and(|said| said.contains("takes 3 argument(s) and got 2")),
"a settle with no verdict must refuse by arity"
);
}
#[test]
fn the_verdicts_are_the_wire_s_two_words_and_there_is_no_third() {
assert_eq!(VERDICTS, ["accept", "reject"]);
}