Start of porting over the walk tests.
This commit is contained in:
parent
26fe996b0d
commit
5760566be0
@ -304,7 +304,7 @@ fn walk_path_from_single_level<'a>(
|
||||
output = new_val?;
|
||||
}
|
||||
|
||||
Ok(WalkResult::FullyWalked(context))
|
||||
Ok(WalkResult::FullyWalked(output))
|
||||
}
|
||||
|
||||
fn new_walk_path<'a>(
|
||||
@ -321,7 +321,7 @@ fn new_walk_path<'a>(
|
||||
return Err(RenderError::NotFound {
|
||||
path: path,
|
||||
breadcrumbs: breadcrumbs.clone(),
|
||||
})
|
||||
});
|
||||
}
|
||||
WalkResult::FullyWalked(new_context) => return Ok(new_context),
|
||||
}
|
||||
@ -332,8 +332,6 @@ fn new_walk_path<'a>(
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: rename walk_path_from_single_level
|
||||
/// Attempts to walk a path from only 1 level in the context breadcrumbs
|
||||
fn walk_path<'a>(
|
||||
context: &'a dyn ContextElement,
|
||||
path: &Vec<&str>,
|
||||
@ -355,8 +353,6 @@ mod tests {
|
||||
use crate::renderer::context_element::Renderable;
|
||||
use crate::renderer::context_element::Walkable;
|
||||
|
||||
#[test]
|
||||
fn test_walk_path() {
|
||||
impl ContextElement for u32 {}
|
||||
impl ContextElement for &str {}
|
||||
impl<I: ContextElement> ContextElement for HashMap<&str, I> {}
|
||||
@ -432,6 +428,37 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_new_walk_path() {
|
||||
let context: HashMap<&str, &str> =
|
||||
[("cat", "kitty"), ("dog", "doggy"), ("tiger", "murderkitty")]
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect();
|
||||
let number_context: HashMap<&str, u32> = [("cat", 1), ("dog", 2), ("tiger", 3)]
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect();
|
||||
let deep_context: HashMap<&str, HashMap<&str, &str>> = [
|
||||
("cat", [("food", "meat")].iter().cloned().collect()),
|
||||
("dog", [("food", "meat")].iter().cloned().collect()),
|
||||
("tiger", [("food", "people")].iter().cloned().collect()),
|
||||
]
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect();
|
||||
|
||||
assert_eq!(
|
||||
new_walk_path(&vec![&context as &dyn ContextElement], &vec!["cat"])
|
||||
.unwrap()
|
||||
.render(&Vec::new())
|
||||
.unwrap(),
|
||||
"kitty".to_owned()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_walk_path() {
|
||||
let context: HashMap<&str, &str> =
|
||||
[("cat", "kitty"), ("dog", "doggy"), ("tiger", "murderkitty")]
|
||||
.iter()
|
||||
|
Loading…
x
Reference in New Issue
Block a user