From ee13dd22be7ee6abc567fbe9b50570a5fbcf4d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Fri, 13 Nov 2020 23:04:59 +0000 Subject: [PATCH] add ability to save raw bytes in tests --- src/test/source.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/test/source.rs b/src/test/source.rs index a84dbf7..45cb1e1 100644 --- a/src/test/source.rs +++ b/src/test/source.rs @@ -16,9 +16,13 @@ impl TempSource { 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); - 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 {