use super::p;
use crate::boundary::codec::decode;
use crate::boundary::codec::start::encode_start;
use crate::boundary::{Action, Gesture};
use crate::opslog::Origin;
use crate::projects::join::JoinState;
use crate::start::{BallSpec, Payload, Prepared};
pub(super) fn surface() -> Vec<Gesture> {
let mut out = Vec::new();
for payload in [
Payload::Bare,
Payload::Path { dir: p("/work") },
Payload::Ball {
project: "proj".into(),
ball: BallSpec::New {
title: "t".into(),
body: "b".into(),
},
},
] {
out.push(Gesture::Act(Action::Prepare {
workspace: "ws".into(),
payload,
}));
}
for join in [
JoinState::ReadyStartable,
JoinState::Blocked,
JoinState::Bound,
JoinState::ClaimedElsewhere,
JoinState::Delivered,
JoinState::UnassignedWorkspace,
JoinState::OrphanedProject,
] {
out.push(Gesture::Act(Action::Prepare {
workspace: "ws".into(),
payload: Payload::Ball {
project: "proj".into(),
ball: BallSpec::Existing {
id: "bl-9".into(),
title: "t".into(),
body: "b".into(),
join,
tags: Vec::new(),
},
},
}));
}
for origin in [Origin::Balls, Origin::Conversation, Origin::World] {
for binding in [None, Some(p("/target"))] {
for seed in [None, Some(0xc0df)] {
out.push(Gesture::Act(Action::Prompt {
prepared: Prepared {
workspace: "ws".into(),
binding: binding.clone(),
goal: "the goal".into(),
origin,
lineage: None,
role: None,
},
goal: "edited goal".into(),
seed,
}));
}
}
}
out.push(Gesture::Act(Action::Prompt {
prepared: Prepared {
workspace: "ws".into(),
binding: Some(p("/target")),
goal: "the goal".into(),
origin: Origin::Balls,
lineage: Some("plan".into()),
role: Some("planner".into()),
},
goal: "edited goal".into(),
seed: None,
}));
out
}
#[test]
fn the_start_envelope_answers_null_to_anything_but_its_own_two() {
let value = encode_start(&Action::Ack);
assert!(value.is_null(), "not a start gesture, so not an envelope");
assert!(decode(&value).is_err(), "and decode refuses it");
}