Derive Default for InMemoryFileAbstraction, remove constructor
This commit is contained in:
parent
6a34e7a8fd
commit
ea80a5a09b
11 changed files with 15 additions and 21 deletions
|
@ -132,7 +132,7 @@ impl<'a> Runtime<'a> {
|
|||
let store_result = if cli_app.use_inmemory_fs() {
|
||||
Store::new_with_backend(storepath,
|
||||
&config,
|
||||
Box::new(InMemoryFileAbstraction::new()))
|
||||
Box::new(InMemoryFileAbstraction::default()))
|
||||
} else {
|
||||
Store::new(storepath, &config)
|
||||
};
|
||||
|
|
|
@ -87,19 +87,13 @@ impl FileAbstractionInstance for InMemoryFileAbstractionInstance {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct InMemoryFileAbstraction {
|
||||
virtual_filesystem: Backend,
|
||||
}
|
||||
|
||||
impl InMemoryFileAbstraction {
|
||||
|
||||
pub fn new() -> InMemoryFileAbstraction {
|
||||
InMemoryFileAbstraction {
|
||||
virtual_filesystem: Arc::new(Mutex::new(RefCell::new(HashMap::new()))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn backend(&self) -> &Backend {
|
||||
&self.virtual_filesystem
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn lazy_file() {
|
||||
let fs = InMemoryFileAbstraction::new();
|
||||
let fs = InMemoryFileAbstraction::default();
|
||||
|
||||
let mut path = PathBuf::from("tests");
|
||||
path.set_file_name("test1");
|
||||
|
@ -124,7 +124,7 @@ Hello World"#, env!("CARGO_PKG_VERSION"))).unwrap();
|
|||
|
||||
#[test]
|
||||
fn lazy_file_multiline() {
|
||||
let fs = InMemoryFileAbstraction::new();
|
||||
let fs = InMemoryFileAbstraction::default();
|
||||
|
||||
let mut path = PathBuf::from("tests");
|
||||
path.set_file_name("test1");
|
||||
|
@ -145,7 +145,7 @@ baz"#, env!("CARGO_PKG_VERSION"))).unwrap();
|
|||
|
||||
#[test]
|
||||
fn lazy_file_multiline_trailing_newlines() {
|
||||
let fs = InMemoryFileAbstraction::new();
|
||||
let fs = InMemoryFileAbstraction::default();
|
||||
|
||||
let mut path = PathBuf::from("tests");
|
||||
path.set_file_name("test1");
|
||||
|
|
|
@ -1176,7 +1176,7 @@ mod store_tests {
|
|||
use file_abstraction::InMemoryFileAbstraction;
|
||||
|
||||
pub fn get_store() -> Store {
|
||||
let backend = Box::new(InMemoryFileAbstraction::new());
|
||||
let backend = Box::new(InMemoryFileAbstraction::default());
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
}
|
||||
|
||||
|
@ -1361,7 +1361,7 @@ mod store_tests {
|
|||
use file_abstraction::InMemoryFileAbstraction;
|
||||
|
||||
let mut store = {
|
||||
let backend = InMemoryFileAbstraction::new();
|
||||
let backend = InMemoryFileAbstraction::default();
|
||||
let backend = Box::new(backend);
|
||||
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
|
@ -1377,7 +1377,7 @@ mod store_tests {
|
|||
}
|
||||
|
||||
{
|
||||
let other_backend = InMemoryFileAbstraction::new();
|
||||
let other_backend = InMemoryFileAbstraction::default();
|
||||
let other_backend = Box::new(other_backend);
|
||||
|
||||
assert!(store.reset_backend(other_backend).is_ok())
|
||||
|
|
|
@ -37,7 +37,7 @@ mod test {
|
|||
use std::path::PathBuf;
|
||||
use libimagstore::file_abstraction::InMemoryFileAbstraction;
|
||||
|
||||
let backend = Box::new(InMemoryFileAbstraction::new());
|
||||
let backend = Box::new(InMemoryFileAbstraction::default());
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ mod tests {
|
|||
|
||||
pub fn get_store() -> Store {
|
||||
use libimagstore::store::InMemoryFileAbstraction;
|
||||
let backend = Box::new(InMemoryFileAbstraction::new());
|
||||
let backend = Box::new(InMemoryFileAbstraction::default());
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
}
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ mod tests {
|
|||
|
||||
pub fn get_store() -> Store {
|
||||
use libimagstore::store::InMemoryFileAbstraction;
|
||||
let backend = Box::new(InMemoryFileAbstraction::new());
|
||||
let backend = Box::new(InMemoryFileAbstraction::default());
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ mod tests {
|
|||
|
||||
fn get_store() -> Store {
|
||||
use libimagstore::file_abstraction::InMemoryFileAbstraction;
|
||||
let backend = Box::new(InMemoryFileAbstraction::new());
|
||||
let backend = Box::new(InMemoryFileAbstraction::default());
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
}
|
||||
|
||||
|
|
|
@ -416,7 +416,7 @@ mod tests {
|
|||
|
||||
pub fn get_store() -> Store {
|
||||
use libimagstore::file_abstraction::InMemoryFileAbstraction;
|
||||
let backend = Box::new(InMemoryFileAbstraction::new());
|
||||
let backend = Box::new(InMemoryFileAbstraction::default());
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
}
|
||||
|
||||
|
|
|
@ -784,7 +784,7 @@ mod test {
|
|||
|
||||
pub fn get_store() -> Store {
|
||||
use libimagstore::file_abstraction::InMemoryFileAbstraction;
|
||||
let backend = Box::new(InMemoryFileAbstraction::new());
|
||||
let backend = Box::new(InMemoryFileAbstraction::default());
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, backend).unwrap()
|
||||
}
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ mod tests {
|
|||
|
||||
pub fn get_store() -> Store {
|
||||
use libimagstore::file_abstraction::InMemoryFileAbstraction;
|
||||
let fs = InMemoryFileAbstraction::new();
|
||||
let fs = InMemoryFileAbstraction::default();
|
||||
Store::new_with_backend(PathBuf::from("/"), &None, Box::new(fs)).unwrap()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue