use std::path::{Path, PathBuf};
use layover_core::{Config, Trigger, validate};
fn examples_dir() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../examples")
}
#[test]
fn the_documented_example_parses_and_validates() {
let path = examples_dir().join("planner.toml");
let config = Config::load(&path).expect("the documented example must remain loadable");
assert_eq!(
validate(&config),
Vec::new(),
"the documented example must validate cleanly"
);
assert_eq!(config.agents.len(), 3);
assert_eq!(config.runners.len(), 3);
assert_eq!(config.entry_agents().count(), 1);
}
#[test]
fn the_documented_example_declares_a_manual_pipeline() {
let config = Config::load(examples_dir().join("planner.toml")).expect("example loads");
let pipeline = config
.pipelines
.get(&"build".into())
.expect("the example declares a `build` pipeline");
assert_eq!(pipeline.trigger, Trigger::Manual);
assert_eq!(pipeline.entry.as_str(), "planner");
assert_eq!(config.scheduled_pipelines().count(), 0);
}
#[test]
fn every_example_agent_says_what_it_is_for() {
for example in ["planner.toml", "workitem-factory/layover.toml"] {
let config = Config::load(examples_dir().join(example)).expect("example loads");
for (name, agent) in &config.agents {
assert!(
agent.description.is_some(),
"`{name}` in {example} has no description"
);
}
}
}