From 94928c33ca461e1e046e027070b79cc6023c49a6 Mon Sep 17 00:00:00 2001 From: Robert Ignat Date: Sun, 25 Jun 2017 16:57:48 +0200 Subject: [PATCH] Use inmemory file system for imag-link tests --- imag-link/src/main.rs | 4 ++++ libimagrt/src/configuration.rs | 4 ++++ libimagrt/src/runtime.rs | 12 ++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/imag-link/src/main.rs b/imag-link/src/main.rs index 8e9bdf0f..a1c19f06 100644 --- a/imag-link/src/main.rs +++ b/imag-link/src/main.rs @@ -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 { diff --git a/libimagrt/src/configuration.rs b/libimagrt/src/configuration.rs index 15e54356..c14063bd 100644 --- a/libimagrt/src/configuration.rs +++ b/libimagrt/src/configuration.rs @@ -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> {} diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs index 3907a60a..2e3f32d7 100644 --- a/libimagrt/src/runtime.rs +++ b/libimagrt/src/runtime.rs @@ -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,