diff options
author | Lars Wirzenius <liw@liw.fi> | 2019-09-25 11:53:50 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2019-09-25 11:53:50 +0300 |
commit | 0b22c103aa735a14a00e8fe03bdf3027d123a36d (patch) | |
tree | 5f2edac3cca332e075a89ddfe017fcc63a4dfce8 /src/lib.rs | |
parent | 587c4cb436a74cf1435e831dde5cad41c9cc5651 (diff) | |
download | roadmap-0b22c103aa735a14a00e8fe03bdf3027d123a36d.tar.gz |
Add: validate step statuses
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -186,6 +186,19 @@ impl Roadmap { // Validate that the parsed, constructed roadmap is valid. fn validate(&self) -> Result<(), Box<dyn std::error::Error>> { + // Does every step has an acceptable status? + for step in self.steps.iter() { + let status = step.status(); + match status { + "" | "goal" | "ready" | "finished" | "next" | "blocked" => (), + _ => { + let msg = format!("step {:?} status {:?} is not allowed", + step.name(), status); + return Result::Err(Box::new(ParseError(msg.into()))); + } + } + } + // Does every dependency exist? for step in self.steps.iter() { for depname in step.dependencies() { @@ -448,6 +461,15 @@ mod tests { } #[test] + fn parse_yaml_unknown_status() { + let r = Roadmap::from_yaml(r#"foo: {status: "bar"}"#); + match r { + Ok(_) => panic!("expected a parse error"), + _ => (), + } + } + + #[test] fn set_missing_goal_status() { let mut r = Roadmap::from_yaml(" goal: |