Watch
0
0
Fork
You've already forked hyperhive
0

templates: one Jinja language (hive-template) for the notify router's flows, flows document version 2

A todo node's key and text were hand-expanded `{field}` strings. They are now Jinja templates rendered through the new hive-template crate (minijinja, an unknown variable is an error), and the controller's save check reads the variables the template uses. The flows document is version 2; a version 1 document reads as version 2 with each `{field}` converted to `{{ field }}`, and the next save writes it.
This commit is contained in:
damocles 2026-11-11 02:13:54 +01:00 • committed by mara
commit 8ef3138863
2 changed files with 306 additions and 91 deletions

View file

@ -375,24 +375,24 @@ mod tests {
store
.put(
notify_flows::KEY,
br#"{"version":2,"flows":[]}"#.to_vec().into(),
br#"{"version":3,"flows":[]}"#.to_vec().into(),
)
.await
.expect("seed");
let got = get_flows(State(state.clone()))
.await
.expect_err("version 2");
.expect_err("version 3");
assert_eq!(got.status, Some(StatusCode::CONFLICT), "{got:?}");
let refused = put_flows(State(state.clone()), Ok(body(0, &[], vec![])))
.await
.expect_err("version 2 is kept");
.expect_err("version 3 is kept");
assert_eq!(refused.status, Some(StatusCode::CONFLICT), "{refused:?}");
let kept = store
.get(notify_flows::KEY)
.await
.expect("read")
.expect("stored");
assert_eq!(&kept[..], br#"{"version":2,"flows":[]}"#);
assert_eq!(&kept[..], br#"{"version":3,"flows":[]}"#);
// Control: garbage that names no version is replaced by a save.
let garbage = store
@ -454,11 +454,11 @@ mod tests {
let mut typo = custom("typo");
if let NodeKind::Todo(sink) = &mut typo.nodes[1].kind {
sink.key = "forge:{repo}#{numbr}:triage".to_owned();
sink.key = "forge:{{ repo }}#{{ numbr }}:triage".to_owned();
}
let refused = put_flows(State(state.clone()), Ok(body(0, &[], vec![typo])))
.await
.expect_err("{numbr} is no field");
.expect_err("numbr is no field");
assert_eq!(refused.status, Some(StatusCode::BAD_REQUEST), "{refused:?}");
// Control: the same flow spelled right is stored.
let _ = put_flows(State(state), Ok(body(0, &[], vec![custom("typo")])))

View file

@ -377,11 +377,11 @@ mod tests {
store
.put(
notify_flows::KEY,
br#"{"version":2,"flows":[]}"#.to_vec().into(),
br#"{"version":3,"flows":[]}"#.to_vec().into(),
)
.await
.expect("seed");
let unreadable = get_dry_run(State(state)).await.expect_err("version 2");
let unreadable = get_dry_run(State(state)).await.expect_err("version 3");
assert_eq!(unreadable.status, Some(StatusCode::CONFLICT));
}