Use inmemory file system for imag-link tests

This commit is contained in:
Robert Ignat 2017-06-25 16:57:48 +02:00 committed by Matthias Beyer
parent b0a5e1727e
commit 94928c33ca
3 changed files with 18 additions and 2 deletions

View file

@ -393,6 +393,10 @@ version = \"0.3.0\"\
fn enable_logging(&self) -> bool {
false
}
fn use_inmemory_fs(&self) -> bool {
true
}
}
fn generate_test_config() -> Option<Configuration> {

View file

@ -289,6 +289,10 @@ pub trait InternalConfiguration {
fn enable_logging(&self) -> bool {
true
}
fn use_inmemory_fs(&self) -> bool {
false
}
}
impl<'a> InternalConfiguration for App<'a, 'a> {}

View file

@ -35,7 +35,7 @@ use error::RuntimeErrorKind;
use error::MapErrInto;
use logger::ImagLogger;
use libimagstore::store::Store;
use libimagstore::store::{Store, InMemoryFileAbstraction};
use spec::CliSpec;
/// The Runtime object
@ -150,7 +150,15 @@ impl<'a> Runtime<'a> {
write!(stderr(), "Store-config: {:?}\n", store_config).ok();
}
Store::new(storepath, store_config).map(|store| {
let store_result = if cli_app.use_inmemory_fs() {
Store::new_with_backend(storepath,
store_config,
Box::new(InMemoryFileAbstraction::new()))
} else {
Store::new(storepath, store_config)
};
store_result.map(|store| {
Runtime {
cli_matches: matches,
configuration: config,