Skip to content

Commit f468d34

Browse files
committed
test(git): cover date filter miss and empty effective commit range error branches
1 parent c4e4234 commit f468d34

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

‎src/git.rs‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,26 @@ mod tests {
15021502
assert!(missing_author.next_desc_commit().is_err());
15031503
}
15041504

1505+
#[test]
1506+
fn test_commit_filters_report_when_only_date_filters_miss_everything() {
1507+
let test_repo = TestRepo::new();
1508+
test_repo.commit_file(
1509+
"history.txt",
1510+
"one\n",
1511+
"Alice Example",
1512+
1513+
1_700_001_000,
1514+
"alice",
1515+
);
1516+
1517+
let mut repo = GitRepository::open(&test_repo.path).unwrap();
1518+
let after_latest = DateTime::from_timestamp(1_700_001_001, 0).unwrap();
1519+
repo.set_after_filter(Some(after_latest));
1520+
1521+
let error = repo.next_desc_commit().unwrap_err().to_string();
1522+
assert!(error.contains("No commits found matching the filters in repository"));
1523+
}
1524+
15051525
#[test]
15061526
fn test_commit_range_lookup_and_validation() {
15071527
let test_repo = TestRepo::new();
@@ -1556,6 +1576,23 @@ mod tests {
15561576
assert!(invalid_repo.set_commit_range("HEAD").is_err());
15571577
}
15581578

1579+
#[test]
1580+
fn test_commit_range_reports_empty_but_valid_ranges() {
1581+
let test_repo = TestRepo::new();
1582+
test_repo.commit_file(
1583+
"src/lib.rs",
1584+
"pub fn only() {}\n",
1585+
"Alice Example",
1586+
1587+
1_700_002_000,
1588+
"only",
1589+
);
1590+
1591+
let repo = GitRepository::open(&test_repo.path).unwrap();
1592+
let error = repo.set_commit_range("HEAD..HEAD").unwrap_err().to_string();
1593+
assert!(error.contains("No non-merge commits found in range"));
1594+
}
1595+
15591596
#[test]
15601597
fn test_commit_range_supports_open_ended_and_defensive_cases() {
15611598
let test_repo = TestRepo::new();

0 commit comments

Comments
 (0)