summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2019-09-25 11:53:50 +0300
committerLars Wirzenius <liw@liw.fi>2019-09-25 11:53:50 +0300
commit0b22c103aa735a14a00e8fe03bdf3027d123a36d (patch)
tree5f2edac3cca332e075a89ddfe017fcc63a4dfce8 /src
parent587c4cb436a74cf1435e831dde5cad41c9cc5651 (diff)
downloadroadmap-0b22c103aa735a14a00e8fe03bdf3027d123a36d.tar.gz
Add: validate step statuses
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 51a8d45..32c880a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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: