Skip to content

Commit

Permalink
Update candidates test check to do comparison by individual element (#12
Browse files Browse the repository at this point in the history
)

* Update candidates test check to do comparison by individual element

* simpler
  • Loading branch information
aandresen-slack authored Jan 17, 2024
1 parent 1ce2063 commit 8a2bd95
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions src/cli/test_runners/test_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,11 @@ impl TestRunner {
}
} else if dir.contains("/migration-candidates/") {
let candidates_file = format!("{}/candidates.txt", dir);
let expected_candidates_contents = fs::read_to_string(candidates_file).unwrap();
let expected_candidates = fs::read_to_string(candidates_file)
.unwrap()
.lines()
.map(String::from)
.collect::<Vec<String>>();

let result = result.unwrap();

Expand All @@ -309,18 +313,40 @@ impl TestRunner {
}
}

if migration_candidates.join("\n") == expected_candidates_contents {
(".".to_string(), Some(result.1), Some(result.0))
} else {
let missing_candidates = expected_candidates
.iter()
.filter(|item| !migration_candidates.contains(item))
.map(String::from)
.collect::<Vec<String>>();
let unexpected_candidates = migration_candidates
.iter()
.filter(|item| !expected_candidates.contains(item))
.map(String::from)
.collect::<Vec<String>>();

if unexpected_candidates.len() > 0 {
test_diagnostics.push((
dir,
dir.clone(),
format!(
"Found unexpected candidates: {}",
unexpected_candidates.join("\n")
),
));
}
if missing_candidates.len() > 0 {
test_diagnostics.push((
dir.clone(),
format!(
"- {}\n+ {}",
expected_candidates_contents,
migration_candidates.join("\n")
"Missing expected candidates: {}",
missing_candidates.join("\n")
),
));
}

if unexpected_candidates.len() > 0 || missing_candidates.len() > 0 {
("F".to_string(), Some(result.1), Some(result.0))
} else {
(".".to_string(), Some(result.1), Some(result.0))
}
} else {
match result {
Expand Down

0 comments on commit 8a2bd95

Please sign in to comment.