From aa1f58cfff3c694e529bea324afeed85ebfe432e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 23 Sep 2017 14:13:16 +0200 Subject: [PATCH] Add test for testing annotation --- lib/entry/libimagentrylink/src/internal.rs | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/entry/libimagentrylink/src/internal.rs b/lib/entry/libimagentrylink/src/internal.rs index 3fd02faf..4e4424b1 100644 --- a/lib/entry/libimagentrylink/src/internal.rs +++ b/lib/entry/libimagentrylink/src/internal.rs @@ -785,6 +785,7 @@ mod test { use libimagstore::store::Store; use super::InternalLinker; + use super::Link; fn setup_logging() { use env_logger; @@ -992,5 +993,34 @@ mod test { assert_eq!(e3.get_internal_links().unwrap().collect::>().len(), 0); } + #[test] + fn test_link_annotating() { + setup_logging(); + let store = get_store(); + let mut entry1 = store.create(PathBuf::from("test_link_annotating-1")).unwrap(); + let mut entry2 = store.create(PathBuf::from("test_link_annotating-2")).unwrap(); + + let res = entry1.add_internal_annotated_link(&mut entry2, String::from("annotation")); + assert!(res.is_ok()); + + { + for link in entry1.get_internal_links().unwrap() { + match link { + Link::Annotated {annotation, ..} => assert_eq!(annotation, "annotation"), + _ => assert!(false, "Non-annotated link found"), + } + } + } + + { + for link in entry2.get_internal_links().unwrap() { + match link { + Link::Id {..} => {}, + Link::Annotated {..} => assert!(false, "Annotated link found"), + } + } + } + } + }