@@ -67,7 +67,7 @@ fn lookup_entry_toplevel() -> crate::Result {
67
67
let filename: BString = "bin" . into ( ) ;
68
68
let oid = hex_to_id ( "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391" ) ;
69
69
70
- assert_eq ! ( entry, Entry { mode, filename, oid } ) ;
70
+ assert_eq ! ( entry, Some ( Entry { mode, filename, oid } ) ) ;
71
71
72
72
Ok ( ( ) )
73
73
}
@@ -80,7 +80,16 @@ fn lookup_entry_nested_path() -> crate::Result {
80
80
let filename: BString = "a" . into ( ) ;
81
81
let oid = hex_to_id ( "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391" ) ;
82
82
83
- assert_eq ! ( entry, Entry { mode, filename, oid } ) ;
83
+ assert_eq ! ( entry, Some ( Entry { mode, filename, oid } ) ) ;
84
+
85
+ Ok ( ( ) )
86
+ }
87
+
88
+ #[ test]
89
+ fn lookup_entry_that_does_not_exist ( ) -> crate :: Result {
90
+ let entry = utils:: lookup_entry_by_path ( "file/does-not-exist" ) ?;
91
+
92
+ assert_eq ! ( entry, None ) ;
84
93
85
94
Ok ( ( ) )
86
95
}
@@ -95,14 +104,14 @@ mod utils {
95
104
Ok ( gix_odb:: at ( root. join ( ".git/objects" ) ) ?)
96
105
}
97
106
98
- pub ( super ) fn lookup_entry_by_path ( path : & str ) -> gix_testtools:: Result < gix_object:: tree:: Entry > {
107
+ pub ( super ) fn lookup_entry_by_path ( path : & str ) -> gix_testtools:: Result < Option < gix_object:: tree:: Entry > > {
99
108
let odb = tree_odb ( ) ?;
100
109
let root_tree_id = hex_to_id ( "ff7e7d2aecae1c3fb15054b289a4c58aa65b8646" ) ;
101
110
102
111
let mut buf = Vec :: new ( ) ;
103
112
let root_tree = odb. find_tree_iter ( & root_tree_id, & mut buf) ?;
104
113
105
114
let mut buf = Vec :: new ( ) ;
106
- Ok ( root_tree. lookup_entry_by_path ( & odb, & mut buf, path) . unwrap ( ) . unwrap ( ) )
115
+ Ok ( root_tree. lookup_entry_by_path ( & odb, & mut buf, path) . unwrap ( ) )
107
116
}
108
117
}
0 commit comments