write_file_contents

Function write_file_contents 

Source
pub fn write_file_contents(path: &str, contents: &[u8]) -> Result<()>
Expand description

Write bytes to a file, creating the file if it does not exist.

Prefer this function if you are creating file content for the purpose of a test. Prefer setup::get_writer_for_file() when you are testing the act of writing to a file.

ยงExample

use common_testing::setup;

#[test]
fn test_1() {
  setup::write_file_contents("./test.txt", &[1, 2, 3]).unwrap();
  // some test code
}