summaryrefslogtreecommitdiff
path: root/src/map.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/map.rs')
-rw-r--r--src/map.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/map.rs b/src/map.rs
index e6a24a9..b592fbd 100644
--- a/src/map.rs
+++ b/src/map.rs
@@ -1,3 +1,5 @@
+use std::collections::HashMap;
+
use textwrap::fill;
pub use crate::from_yaml;
@@ -21,8 +23,10 @@ impl Roadmap {
/// Create a new, empty roadmap.
///
/// You probably want the `from_yaml` function instead.
- pub fn new() -> Self {
- Self::default()
+ pub fn new(map: HashMap<String, Step>) -> Self {
+ Self {
+ steps: map.values().cloned().collect(),
+ }
}
// Find steps that nothing depends on.
@@ -220,13 +224,13 @@ mod tests {
#[test]
fn new_roadmap() {
- let roadmap = Roadmap::new();
+ let roadmap = Roadmap::default();
assert_eq!(roadmap.step_names().count(), 0);
}
#[test]
fn add_step_to_roadmap() {
- let mut roadmap = Roadmap::new();
+ let mut roadmap = Roadmap::default();
let first = Step::new("first", "the first step");
roadmap.add_step(first);
let names: Vec<&str> = roadmap.step_names().collect();
@@ -235,7 +239,7 @@ mod tests {
#[test]
fn get_step_from_roadmap() {
- let mut roadmap = Roadmap::new();
+ let mut roadmap = Roadmap::default();
let first = Step::new("first", "the first step");
roadmap.add_step(first);
let gotit = roadmap.get_step("first").unwrap();
@@ -279,7 +283,7 @@ blocked:
#[test]
fn empty_dot() {
- let roadmap = Roadmap::new();
+ let roadmap = Roadmap::default();
match roadmap.format_as_dot(999) {
Err(_) => (),
_ => panic!("expected error for empty roadmap"),
@@ -288,7 +292,7 @@ blocked:
#[test]
fn simple_dot() {
- let mut roadmap = Roadmap::new();
+ let mut roadmap = Roadmap::default();
let mut first = Step::new("first", "");
first.set_status(Status::Ready);
let mut second = Step::new("second", "");