Skip to content

Commit

Permalink
Fix breaking test
Browse files Browse the repository at this point in the history
Not sure how this was able to get to master and not breaking merges
until now. I might review the integration test later, because there
is a little too much magic numbers involved.
  • Loading branch information
FedericoPonzi committed Aug 2, 2024
1 parent 5c35d7d commit 2afa020
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/section_general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ fn test_output_redirection() {

#[test]
fn test_output_log_rotation() {
// todo: review this test
let pattern = "Hello";
let max_size = 50;
let num_logs = 4;
Expand All @@ -77,7 +78,7 @@ sleep 10
exit 0
"#,
// How many patterns do we need to repeat to reach required file size.
10 + (max_size * num_logs) / (pattern.len() + 1),
15 + (max_size * num_logs) / (pattern.len() + 1),
pattern,
);
let service = [
Expand All @@ -92,8 +93,21 @@ exit 0
None,
);
cmd.assert().success().stdout(is_empty());

// print the content of temp_dir directory:
let mut ls = std::process::Command::new("ls")

Check warning on line 98 in tests/section_general.rs

View workflow job for this annotation

GitHub Actions / Test (stable)

variable does not need to be mutable

Check warning on line 98 in tests/section_general.rs

View workflow job for this annotation

GitHub Actions / Test (beta)

variable does not need to be mutable

Check warning on line 98 in tests/section_general.rs

View workflow job for this annotation

GitHub Actions / Test (nightly)

variable does not need to be mutable
.arg("-l")
.arg(temp_dir.path())
.spawn()
.unwrap();
let output = ls.wait_with_output().unwrap();
println!("{}", String::from_utf8_lossy(&output.stdout));

let content = std::fs::read_to_string(last_output).unwrap();
assert!(content.starts_with(pattern));
assert!(
content.starts_with(pattern),
"Expeccted '{content}' to start with '{pattern}'"
);
}

#[test]
Expand Down

0 comments on commit 2afa020

Please sign in to comment.