Add test whether setting tags works

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-06-29 16:58:26 +02:00
parent c5519da011
commit ae9fbe866f
3 changed files with 45 additions and 0 deletions

View file

@ -42,3 +42,6 @@ version = "^2.29"
default-features = false
features = ["color", "suggestions", "wrap_help"]
[dev-dependencies]
env_logger = "0.5"

View file

@ -48,6 +48,8 @@ extern crate serde;
extern crate filters;
#[macro_use] extern crate failure;
#[cfg(test)] extern crate env_logger;
extern crate libimagstore;
extern crate libimagerror;

View file

@ -116,3 +116,43 @@ impl Tagable for Entry {
}
#[cfg(test)]
mod tests {
use std::path::PathBuf;
use toml_query::read::TomlValueReadTypeExt;
use libimagstore::store::Store;
use super::*;
fn setup_logging() {
let _ = ::env_logger::try_init();
}
fn get_store() -> Store {
Store::new_inmemory(PathBuf::from("/"), &None).unwrap()
}
#[test]
fn test_tag_set_sets_tag() {
setup_logging();
let store = get_store();
let name = "test-tag-set-sets-tags";
debug!("Creating default entry");
let id = PathBuf::from(String::from(name));
let mut entry = store.create(id).unwrap();
let tags = vec![String::from("testtag")];
entry.set_tags(&tags).unwrap();
let v = entry.get_header().read_string("tags.values.[0]").unwrap();
assert!(v.is_some());
let v = v.unwrap();
assert_eq!(v, "testtag");
}
}