use phoxal_bus::{BusConfig, BusOwner, EndpointDescriptor, ExecutionId};
use phoxal_macros::phoxal_protocol;
mod payload {
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(tag = "schema")]
pub enum Hello {
#[serde(rename = "supervisor.hello/v0")]
V0 { token: String },
}
}
phoxal_protocol! {
protocol supervisor {
connect {
command hello: Setpoint<crate::payload::Hello>;
}
}
}
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn a_protocol_topic_composes_under_the_execution_scoped_root() {
let config = BusConfig::for_participant(
ExecutionId::mint(),
phoxal_bus::ParticipantId::new("composition").expect("valid participant id"),
Vec::new(),
);
let execution = config.execution();
let (owner, bus) = BusOwner::open(config).await.expect("open in-process bus");
assert_eq!(
<supervisor::endpoint::connect::HelloEndpoint as EndpointDescriptor>::TOPIC,
"supervisor/connect/hello"
);
assert_eq!(bus.root(), format!("phoxal/{execution}"));
assert_eq!(
bus.full_key(<supervisor::endpoint::connect::HelloEndpoint as EndpointDescriptor>::TOPIC),
format!("phoxal/{execution}/supervisor/connect/hello")
);
owner.close().await;
}