From 0aea9151dd39d83c4067c1a4d9a3183babba54aa Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Sep 2017 22:19:42 +0200 Subject: [PATCH] Add test for faulty link --- .../libimagentrymarkdown/src/processor.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/entry/libimagentrymarkdown/src/processor.rs b/lib/entry/libimagentrymarkdown/src/processor.rs index ea85d7b9..2664a0f1 100644 --- a/lib/entry/libimagentrymarkdown/src/processor.rs +++ b/lib/entry/libimagentrymarkdown/src/processor.rs @@ -289,5 +289,25 @@ mod tests { } } + #[test] + fn test_process_one_existing_file_linked_faulty() { + setup_logging(); + let store = get_store(); + + let mut base = store.create(PathBuf::from("test-2.1")).unwrap(); + *base.get_content_mut() = format!("This is an example entry with one [link](/test-2.2)"); + + let update = store.update(&mut base); + assert!(update.is_ok()); + + let processor = LinkProcessor::default() + .process_internal_links(true) + .create_internal_targets(false) + .process_external_links(false) + .process_refs(false); + + let result = processor.process(&mut base, &store); + assert!(result.is_err(), "Should be Err(_), but is Ok(())"); + } }