Struct rfs_tester::rfs::fs_tester::FsTester [−][src]
File System Tester used to create some configured structure in directory with files and links to them. FsTester can start custom test closure and remove fs structure after testing complete or fail.
Fields
config: Config
base_dir: String
Implementations
impl FsTester
[src]
pub fn parse_config(config_str: &str) -> Result<Config, Box<dyn Error>>
[src]
Config parser config can be string in yaml or json format:
Example for yaml
let simple_conf_str = "--- - directory: name: test content: - file: name: test.txt content: inline_bytes: - 116 - 101 - 115 - 116 ";
Example for json
let simple_conf_str = "[{\"directory\":{\"name\":\"test\",\"content\":[{\"file\":{\"name\":\"test.txt\",\"content\":{\"inline_bytes\":[116,101,115,116]}}}]}}]";
pub fn new(config_str: &str, start_point: &str) -> FsTester
[src]
create the test directory, files and link set config_str - configuration of test directory in yaml or json format start_point - directory name where will create testing directory, it should presents in FS.
pub fn perform_fs_test<F>(&self, test_proc: F) where
F: Fn(&str) -> Result<()>,
[src]
F: Fn(&str) -> Result<()>,
Start test_proc function. The test unit can define as closure parameter of perform_fs_test. The dirname closure parameter is name of generated temporary test directory which contains fs units set. We cannot know full name before testing start because it has random number in the end of name. FsTester has known it after instance build.
Example
use std::fs; const YAML_DIR_WITH_TEST_FILE_FROM_CARGO_TOML: &str = "--- - directory: name: test content: - file: name: test_from_cargo.toml content: original_file: Cargo.toml "; let tester = FsTester::new(YAML_DIR_WITH_TEST_FILE_FROM_CARGO_TOML, "."); tester.perform_fs_test(|dirname| { // ^^^^^^^ name with appended random at the end of name let inner_file_name = format!("{}/{}", dirname, "test_from_cargo.toml"); let metadata = fs::metadata(inner_file_name)?; assert!(metadata.len() > 0); Ok(()) });
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for FsTester
impl Send for FsTester
impl Sync for FsTester
impl Unpin for FsTester
impl UnwindSafe for FsTester
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,