get_writer_for_file

Function get_writer_for_file 

Source
pub fn get_writer_for_file(path: &str) -> Result<BufWriter<File>>
Expand description

Get a writer for a file, creating the file if it does not exist. Use this to create temporary files for testing and comparison.

Prefer this function if you are testing dynamic content being written to a file during the test, and remember to call flush() when you are done. Prefer setup::write_file_contents() when you need to create content in a file for the purpose of a test.

ยงExample

use common_testing::setup;

#[test]
fn test_1() {
 let mut writer = setup::get_writer_for_file("./test.txt").unwrap();
 // some test code
}