Add test for create()

This commit is contained in:
Matthias Beyer 2017-09-03 22:00:34 +02:00
parent c870a0a240
commit 014daee93b
3 changed files with 58 additions and 1 deletions

View file

@ -27,3 +27,18 @@ libimagutil = { version = "0.4.0", path = "../../../lib/etc/libimagutil" }
[features] [features]
early-panic = [ "libimagstore/early-panic" ] early-panic = [ "libimagstore/early-panic" ]
[dev-dependencies.libimagutil]
version = "0.4.0"
path = "../../../lib/etc/libimagutil"
default-features = false
features = ["testing"]
[dev-dependencies.libimagrt]
version = "0.4.0"
path = "../../../lib/core/libimagrt"
default-features = false
features = ["testing"]
[dev-dependencies.toml-query]
version = "0.3"

View file

@ -177,3 +177,39 @@ fn string_from_raw_src(raw_src: &str) -> String {
} }
content content
} }
#[cfg(test)]
mod tests {
use super::create;
use std::path::PathBuf;
use toml_query::read::TomlValueReadExt;
use toml::Value;
make_mock_app! {
app "imag-link";
modulename mock;
version "0.4.0";
with help "imag-link mocking app";
}
use self::mock::generate_test_runtime;
#[test]
fn test_create_simple() {
let test_name = "test_create_simple";
let rt = generate_test_runtime(vec!["create", "-p", "test_create_simple"]).unwrap();
create(&rt);
let e = rt.store().get(PathBuf::from(test_name));
assert!(e.is_ok());
let e = e.unwrap();
assert!(e.is_some());
let e = e.unwrap();
let version = e.get_header().read("imag.version").map(Option::unwrap).unwrap();
assert_eq!(Value::String(String::from("0.4.0")), *version);
}
}

View file

@ -35,13 +35,19 @@
extern crate clap; extern crate clap;
#[macro_use] extern crate log; #[macro_use] extern crate log;
extern crate toml; extern crate toml;
#[cfg(test)] extern crate toml_query;
#[macro_use] extern crate version; #[macro_use] extern crate version;
extern crate libimagrt; extern crate libimagrt;
extern crate libimagstore; extern crate libimagstore;
extern crate libimagutil;
#[macro_use] extern crate libimagerror; #[macro_use] extern crate libimagerror;
#[cfg(test)]
#[macro_use]
extern crate libimagutil;
#[cfg(not(test))]
extern crate libimagutil;
use libimagrt::setup::generate_runtime_setup; use libimagrt::setup::generate_runtime_setup;
mod create; mod create;