1
0
mirror of https://github.com/sharkdp/bat synced 2026-07-23 17:03:18 +00:00

Add test with fauly git repo version

This commit is contained in:
blinxen
2026-05-31 11:57:55 +02:00
parent 69f40d9d8a
commit 98f09fd6f3
+13
View File
@@ -178,4 +178,17 @@ mod tests {
assert_eq!(changes.get(&1), Some(&LineChange::RemovedAbove));
assert_eq!(changes.get(&2), Some(&LineChange::Added));
}
#[test]
fn faulty_git_version_does_not_panic() {
let repo = setup_repo();
let file = create_and_track_file(&repo, "file.txt");
std::fs::write(&file, "line 1\nline 2 modified\n").expect("can write file");
// changes are detected
assert_eq!(get_git_diff(&file).expect("one change").len(), 2);
// write invalid repositoryformatversion
git(repo.path(), &["config", "core.repositoryformatversion", "one"]);
// changes are no longer detected
assert_eq!(get_git_diff(&file), None);
}
}