use phoxal_bus::{Bus, BusConfig, ContractBody};
use phoxal_macros::phoxal_api_tree;
phoxal_api_tree! {
protocol supervisor {
connect {
#[serde(tag = "schema")]
enum Hello {
#[serde(rename = "supervisor.hello/v0")]
V0 { token: String },
}
topic hello: command Hello;
}
}
}
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn a_protocol_topic_composes_under_the_execution_scoped_root() {
let config = BusConfig::in_process("composition");
let execution = config.execution;
let bus = Bus::open(config).await.expect("open in-process bus");
assert_eq!(
<supervisor::connect::Hello as ContractBody>::TOPIC,
"supervisor/connect/hello"
);
assert_eq!(bus.root(), format!("phoxal/{execution}"));
assert_eq!(
bus.full_key(<supervisor::connect::Hello as ContractBody>::TOPIC),
format!("phoxal/{execution}/supervisor/connect/hello")
);
bus.close().await.expect("close in-process bus");
}