Trait testpath::Fixtures [−][src]
pub trait Fixtures: TestPath {
fn create_file<P>(&self, name: P, content: &[u8]) -> &Self
where
P: AsRef<Path> + Sized,
Self: Sized,
{ ... }
fn create_dir<P>(&self, name: P) -> &Self
where
P: AsRef<Path> + Sized,
Self: Sized,
{ ... }
fn install_from<P>(&self, from: P) -> &Self
where
P: AsRef<Path> + Sized,
Self: Sized,
{ ... }
fn delete<N>(&self, _name: &N) -> &Self
where
N: AsRef<Path> + ?Sized,
{ ... }
}
Expand description
Trait for test directoy objects
Provided methods
Create a file with the given content in the test directory. Any leading directories are created automatically. The file itself must not already exist.
Create a directory within the test directory. Any leading directories are created automatically. The path must not exist already.
Install something (from outside) into ‘self’. ‘from’ must be some existing directory or a file, symlinks are resolved.
Following semantics apply when from
is a file:
self is | What is done |
---|---|
nonexistant | self last component is the new filename, parent dirs are created |
dir | from is copied into self , but won’t overwrite an existing file |
file | self gets overwritten |
Following semantics apply when from
is a directory:
self is | What is done |
---|---|
nonexistant | self including parents are created, the content of from is copied into that |
dir | the content of from is copied into self |
file | ERROR |
Delete an element from a testpath. Directories are deleted as well. This trait
functions defaults to unimplemented
because it is deemed to be dangerous. Only the
trait implementations which create an disposable directory implement it.