Skip to main content

seeds

Function seeds 

Source
pub fn seeds(root: &Path, suite: &EconomicsSuite) -> Vec<String>
Expand description

The seeds of a context suite: the ids of the plan’s issues, from the file names under the suite’s seeds directory, sorted.

Only .yaml files name a seed, by their stem, so a README beside them is not measured. A suite that declares no seeds directory (a live suite), or one whose directory is missing, has no seeds rather than an error: the suite then measures nothing.

use majordomus_cli::economics::context::seeds;
use majordomus_cli::economics::model::EconomicsSuite;
let dir = tempfile::tempdir().unwrap();
std::fs::create_dir(dir.path().join("seeds")).unwrap();
for f in ["I0302.yaml", "I0301.yaml", "README.md"] {
    std::fs::write(dir.path().join("seeds").join(f), "").unwrap();
}
let mut suite: EconomicsSuite = serde_json::from_value(serde_json::json!({
    "schema": "economics-suite/v1", "id": "context", "version": 1, "kind": "context",
    "title": "Context selection", "seeds": "seeds", "freshness_inputs": []
}))
.unwrap();
assert_eq!(seeds(dir.path(), &suite), ["I0301", "I0302"]);
suite.seeds = None;
assert!(seeds(dir.path(), &suite).is_empty());