nextsync-rust/tests/utils/files_utils.rs
2024-03-11 14:47:05 +01:00

26 lines
746 B
Rust

use std::io::{BufReader, BufRead, Write};
use std::fs::{File};
use std::path::PathBuf;
pub fn has_files(full_path: PathBuf, file: &str, content: &str, test_id: String) -> bool
{
if !full_path.exists() {
println!("id: {}", test_id.clone());
eprintln!("File '{}' doesn't exists on the server", file);
return false;
}
let f = File::open(full_path).unwrap();
for line in BufReader::new(f).lines(){
if let Ok(line) = line {
if line != content {
println!("id: {}", test_id);
eprintln!("File '{}' is not equal, {} != {}", file, line, content);
return false;
}
return line == content;
}
}
return true;
}