Add test for processing entry without links
This commit is contained in:
parent
9c68514dfb
commit
0a60f5ca55
3 changed files with 40 additions and 1 deletions
|
@ -18,9 +18,11 @@ log = "0.3"
|
|||
hoedown = "5.0.0"
|
||||
url = "1.2"
|
||||
error-chain = "0.10"
|
||||
env_logger = "0.3"
|
||||
|
||||
libimagstore = { version = "0.4.0", path = "../../../lib/core/libimagstore" }
|
||||
libimagerror = { version = "0.4.0", path = "../../../lib/core/libimagerror" }
|
||||
libimagentrylink = { version = "0.4.0", path = "../../../lib/entry/libimagentrylink/" }
|
||||
libimagentryref = { version = "0.4.0", path = "../../../lib/entry/libimagentryref/" }
|
||||
libimagutil = { version = "0.4.0", path = "../../../lib/etc/libimagutil/" }
|
||||
|
||||
|
|
|
@ -40,13 +40,13 @@ extern crate url;
|
|||
extern crate libimagstore;
|
||||
extern crate libimagerror;
|
||||
extern crate libimagentrylink;
|
||||
extern crate libimagentryref;
|
||||
extern crate libimagutil;
|
||||
#[macro_use] extern crate error_chain;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate env_logger;
|
||||
|
||||
#[allow(unused)]
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
|
|
|
@ -209,3 +209,40 @@ impl Default for LinkProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use libimagstore::store::Store;
|
||||
|
||||
fn setup_logging() {
|
||||
use env_logger;
|
||||
let _ = env_logger::init().unwrap_or(());
|
||||
}
|
||||
|
||||
pub fn get_store() -> Store {
|
||||
use libimagstore::file_abstraction::InMemoryFileAbstraction;
|
||||
let fs = InMemoryFileAbstraction::new();
|
||||
Store::new_with_backend(PathBuf::from("/"), None, Box::new(fs)).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_process_no_links() {
|
||||
setup_logging();
|
||||
let store = get_store();
|
||||
|
||||
let mut base = store.create(PathBuf::from("test-1")).unwrap();
|
||||
*base.get_content_mut() = format!("This is an example entry with no links");
|
||||
|
||||
let update = store.update(&mut base);
|
||||
assert!(update.is_ok());
|
||||
|
||||
let processor = LinkProcessor::default();
|
||||
|
||||
let result = processor.process(&mut base, &store);
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue