add ability to save raw bytes in tests

This commit is contained in:
Cyryl Płotnicki 2020-11-13 23:04:59 +00:00
parent f83baa0515
commit ee13dd22be

View file

@ -16,9 +16,13 @@ impl TempSource {
Ok(Self { directory: tempdir()? }) Ok(Self { directory: tempdir()? })
} }
pub fn write_text_to_file(&self, filename: &str, text: &str) -> Result<(), Error> { pub fn write_bytes_to_file(&self, filename: &str, bytes: &[u8]) -> Result<(), Error> {
let path = self.file_path(filename); let path = self.file_path(filename);
Ok(File::create(path)?.write_all(text.as_bytes())?) Ok(File::create(path)?.write_all(bytes)?)
}
pub fn write_text_to_file(&self, filename: &str, text: &str) -> Result<(), Error> {
self.write_bytes_to_file(filename, text.as_bytes())
} }
pub fn path(&self) -> &Path { pub fn path(&self) -> &Path {