get_read_only_file

Function get_read_only_file 

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

Get a read-only file handle. Use for fixtures you never want to change.

Prefer setup::get_file_contents() when you need to compare the contents of a file. Prefer setup::get_reader_for_file() when you need a BufReader.

Use to avoid random dependencies in test files for rare test cases.

ยงExample

use common_testing::setup;

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