History

[commitgraph] refactor

Sebastian Thiel committed 6 years ago

Commit 2ed00371 parent 70269613 files · +15 −11Browse files

Showing the changes to git-commitgraph/tests/commitgraph.rs (1 of 3 files). Show all

Unified · Split

git-commitgraph/tests/commitgraph.rs+8−4
@@ -9,6 +9,8 @@ use std::{ · 8 unmodified lines
9 process::Command,9 process::Command,
10};10};
11 11
12type Result = std::result::Result<(), Box<dyn std::error::Error>>;
13
12mod access;14mod access;
13 15
14pub fn check_common(cg: &Graph, expected: &HashMap<String, RefInfo, impl BuildHasher>) {16pub fn check_common(cg: &Graph, expected: &HashMap<String, RefInfo, impl BuildHasher>) {
@@ -35,6 +37,7 @@ pub fn check_common(cg: &Graph, expected: &HashMap<String, RefInfo, impl BuildHa · 20 unmodified lines
35 .expect("find RefInfo by id")37 .expect("find RefInfo by id")
36 })38 })
37 .collect();39 .collect();
40
38 let commit = cg.commit_at(ref_info.pos());41 let commit = cg.commit_at(ref_info.pos());
39 assert_eq!(commit.id(), ref_info.id());42 assert_eq!(commit.id(), ref_info.id());
40 assert_eq!(commit.root_tree_id(), ref_info.root_tree_id());43 assert_eq!(commit.root_tree_id(), ref_info.root_tree_id());
@@ -45,7 +48,7 @@ pub fn check_common(cg: &Graph, expected: &HashMap<String, RefInfo, impl BuildHa · 4 unmodified lines
45 assert_eq!(48 assert_eq!(
46 commit49 commit
47 .iter_parents()50 .iter_parents()
48 .collect::<Result<Vec<_>, _>>()51 .collect::<std::result::Result<Vec<_>, _>>()
49 .expect("failed to access commit's parents"),52 .expect("failed to access commit's parents"),
50 expected_parents.iter().map(|x| x.pos()).collect::<Vec<_>>()53 expected_parents.iter().map(|x| x.pos()).collect::<Vec<_>>()
51 );54 );
@@ -134,10 +137,11 @@ pub fn inspect_refs(repo_dir: impl AsRef<Path>, refs: &[&'static str]) -> HashMa · 82 unmodified lines
134 infos.sort_by_key(|x| x.1);137 infos.sort_by_key(|x| x.1);
135 138
136 let get_pos = |id: borrowed::Id| -> GraphPosition {139 let get_pos = |id: borrowed::Id| -> GraphPosition {
137 let pos = infos140 let pos: u32 = infos
138 .binary_search_by_key(&id, |x| x.1.to_borrowed())141 .binary_search_by_key(&id, |x| x.1.to_borrowed())
139 .expect("sorted_ids to contain id");142 .expect("sorted_ids to contain id")
140 let pos: u32 = pos.try_into().expect("graph position to fit in u32");143 .try_into()
144 .expect("graph position to fit in u32");
141 GraphPosition(pos)145 GraphPosition(pos)
142 };146 };
143 147