@@ -60,14 +60,7 @@ fn everything() -> crate::Result {
6060
6161#[ test]
6262fn lookup_entry_toplevel ( ) -> crate :: Result {
63- let odb = utils:: tree_odb ( ) ?;
64- let root_tree_id = hex_to_id ( "ff7e7d2aecae1c3fb15054b289a4c58aa65b8646" ) ;
65-
66- let mut buf = Vec :: new ( ) ;
67- let root_tree = odb. find_tree_iter ( & root_tree_id, & mut buf) ?;
68-
69- let mut buf = Vec :: new ( ) ;
70- let entry = root_tree. lookup_entry_by_path ( & odb, & mut buf, "bin" ) . unwrap ( ) . unwrap ( ) ;
63+ let entry = utils:: lookup_entry_by_path ( "bin" ) ?;
7164
7265 assert ! ( matches!( entry, Entry { .. } ) ) ;
7366 assert_eq ! ( entry. filename, "bin" ) ;
@@ -77,17 +70,7 @@ fn lookup_entry_toplevel() -> crate::Result {
7770
7871#[ test]
7972fn lookup_entry_nested_path ( ) -> crate :: Result {
80- let odb = utils:: tree_odb ( ) ?;
81- let root_tree_id = hex_to_id ( "ff7e7d2aecae1c3fb15054b289a4c58aa65b8646" ) ;
82-
83- let mut buf = Vec :: new ( ) ;
84- let root_tree = odb. find_tree_iter ( & root_tree_id, & mut buf) ?;
85-
86- let mut buf = Vec :: new ( ) ;
87- let entry = root_tree
88- . lookup_entry_by_path ( & odb, & mut buf, "file/a" )
89- . unwrap ( )
90- . unwrap ( ) ;
73+ let entry = utils:: lookup_entry_by_path ( "file/a" ) ?;
9174
9275 assert ! ( matches!( entry, Entry { .. } ) ) ;
9376 assert_eq ! ( entry. filename, "a" ) ;
@@ -96,8 +79,23 @@ fn lookup_entry_nested_path() -> crate::Result {
9679}
9780
9881mod utils {
82+ use crate :: hex_to_id;
83+
84+ use gix_object:: FindExt ;
85+
9986 pub ( super ) fn tree_odb ( ) -> gix_testtools:: Result < gix_odb:: Handle > {
10087 let root = gix_testtools:: scripted_fixture_read_only ( "make_trees.sh" ) ?;
10188 Ok ( gix_odb:: at ( root. join ( ".git/objects" ) ) ?)
10289 }
90+
91+ pub ( super ) fn lookup_entry_by_path ( path : & str ) -> gix_testtools:: Result < gix_object:: tree:: Entry > {
92+ let odb = tree_odb ( ) ?;
93+ let root_tree_id = hex_to_id ( "ff7e7d2aecae1c3fb15054b289a4c58aa65b8646" ) ;
94+
95+ let mut buf = Vec :: new ( ) ;
96+ let root_tree = odb. find_tree_iter ( & root_tree_id, & mut buf) ?;
97+
98+ let mut buf = Vec :: new ( ) ;
99+ Ok ( root_tree. lookup_entry_by_path ( & odb, & mut buf, path) . unwrap ( ) . unwrap ( ) )
100+ }
103101}
0 commit comments