Add test to test ref creation

This commit is contained in:
Matthias Beyer 2017-09-06 16:27:59 +02:00
parent 24985a2384
commit 98aa7bf716

View file

@ -397,5 +397,35 @@ mod tests {
assert_eq!("test-5.1", link_links[0].to_str().unwrap()); assert_eq!("test-5.1", link_links[0].to_str().unwrap());
} }
} }
#[test]
fn test_process_one_ref() {
setup_logging();
let store = get_store();
let mut base = store.create(PathBuf::from("test-5.1")).unwrap();
// As the ref target must exist, we're using /etc/hosts here
*base.get_content_mut() = format!("An [example ref](file:///etc/hosts) is here.");
let update = store.update(&mut base);
assert!(update.is_ok());
let processor = LinkProcessor::default()
.process_internal_links(false)
.create_internal_targets(false)
.process_external_links(false)
.process_refs(true);
let result = processor.process(&mut base, &store);
assert!(result.is_ok(), "Should be Ok(()): {:?}", result);
let entries = store.entries();
assert!(entries.is_ok());
let entries : Vec<_> = entries.unwrap().collect();
assert_eq!(2, entries.len(), "Expected 2 links, got: {:?}", entries);
println!("{:?}", entries);
}
} }