radicle: Fix flaky test `counts_by_repo`

This commit is contained in:
cloudhead 2024-11-21 16:05:01 +01:00
parent a7e96131ce
commit 2d13591ec2
No known key found for this signature in database
1 changed files with 5 additions and 6 deletions

View File

@ -443,7 +443,7 @@ mod test {
} }
#[test] #[test]
fn test_count_by_repos() { fn test_counts_by_repo() {
let mut db = Store::open(":memory:").unwrap(); let mut db = Store::open(":memory:").unwrap();
let repo1 = arbitrary::gen::<RepoId>(1); let repo1 = arbitrary::gen::<RepoId>(1);
let repo2 = arbitrary::gen::<RepoId>(1); let repo2 = arbitrary::gen::<RepoId>(1);
@ -466,15 +466,14 @@ mod test {
assert!(db.insert(&repo1, &update2, time).unwrap()); assert!(db.insert(&repo1, &update2, time).unwrap());
assert!(db.insert(&repo2, &update3, time).unwrap()); assert!(db.insert(&repo2, &update3, time).unwrap());
let mut counts = db let counts = db
.counts_by_repo() .counts_by_repo()
.unwrap() .unwrap()
.collect::<Result<Vec<_>, _>>() .collect::<Result<std::collections::HashMap<_, _>, _>>()
.unwrap(); .unwrap();
counts.sort();
assert_eq!(counts.first().unwrap(), &(repo1, 2)); assert_eq!(counts.get(&repo1).unwrap(), &2);
assert_eq!(counts.last().unwrap(), &(repo2, 1)); assert_eq!(counts.get(&repo2).unwrap(), &1);
} }
#[test] #[test]