diff --git a/v0.5/fastn-unresolved/src/parser/import.rs b/v0.5/fastn-unresolved/src/parser/import.rs index 3e7e66757..e3dff5493 100644 --- a/v0.5/fastn-unresolved/src/parser/import.rs +++ b/v0.5/fastn-unresolved/src/parser/import.rs @@ -108,7 +108,13 @@ fn aliasable(s: &str) -> fastn_unresolved::AliasableIdentifier { #[cfg(test)] mod tests { - fastn_unresolved::tt!(super::import, |mut d| Box::new(d.imports.pop().unwrap())); + fastn_unresolved::tt!(super::import, |mut d, s, expected| { + // todo: assert everything else is empty in document + assert!(d.content.is_empty()); + assert_eq!(d.imports.len(), 1); + + fastn_section::JDebug::debug(&d.imports.pop().unwrap(), s) == expected + }); #[test] fn test_import() { diff --git a/v0.5/fastn-unresolved/src/parser/mod.rs b/v0.5/fastn-unresolved/src/parser/mod.rs index 7062931ae..eaea22525 100644 --- a/v0.5/fastn-unresolved/src/parser/mod.rs +++ b/v0.5/fastn-unresolved/src/parser/mod.rs @@ -42,10 +42,10 @@ pub fn parse(_document_id: &str, source: &str) -> fastn_unresolved::Document { #[cfg(test)] #[track_caller] /// t1 takes a function parses a single section. and another function to extract the debug value -fn t1(source: &str, expected: serde_json::Value, parser: PARSER, debug: DEBUG) +fn t1(source: &str, expected: serde_json::Value, parser: PARSER, tester: TESTER) where PARSER: Fn(&str, fastn_section::Section, &mut fastn_unresolved::Document), - DEBUG: FnOnce(fastn_unresolved::Document) -> Box, + TESTER: FnOnce(fastn_unresolved::Document, &str, serde_json::Value) -> bool, { println!("--------- testing -----------\n{source}\n--------- source ------------"); @@ -60,7 +60,7 @@ where // assert everything else is empty parser(source, section, &mut document); - assert_eq!(debug(document).debug(source), expected); + assert!(tester(document, source, expected)); } #[cfg(test)]