Skip to content

Commit

Permalink
fix: file.flush after each file.write_all (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
matzuk authored Sep 4, 2024
1 parent 004aed3 commit 6ed8acb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/artifacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ async fn patch_file(path: &Path) -> io::Result<()> {
// Write the patched JSON back to the file
let mut file = File::create(&path)?;
file.write_all(serde_json::to_string_pretty(&json_value)?.as_bytes())?;
file.flush()?;

Ok(())
}
Expand Down Expand Up @@ -227,6 +228,7 @@ mod tests {
let json_file_path = allure_results_path.join("sample.json");
let mut file = File::create(&json_file_path).unwrap();
file.write_all(original_json.as_bytes()).unwrap();
file.flush().unwrap();

let result = patch_allure_paths(temp_dir.path()).await;
assert!(result.is_ok());
Expand All @@ -253,6 +255,7 @@ mod tests {
let json_file_path = allure_results_path.join("sample.json");
let mut file = File::create(&json_file_path).unwrap();
file.write_all(original_json.as_bytes()).unwrap();
file.flush().unwrap();

let result = patch_allure_paths(temp_dir.path()).await;
assert!(result.is_ok());
Expand Down
1 change: 1 addition & 0 deletions src/interactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ impl TriggerTestRunInteractor {
let mut file = File::create(&result_file).await?;
let data = serialize_event(&result_file, &event)?;
file.write_all(data.as_bytes()).await?;
file.flush().await?;
}

Ok(true)
Expand Down

0 comments on commit 6ed8acb

Please sign in to comment.