1
1
mod init {
2
+ use bstr:: ByteSlice ;
2
3
use std:: path:: { Path , PathBuf } ;
3
4
4
5
use git_index:: { entry, Version } ;
@@ -34,13 +35,24 @@ mod init {
34
35
assert ! ( entry. flags. is_empty( ) ) ;
35
36
assert_eq ! ( entry. mode, entry:: Mode :: FILE ) ;
36
37
assert_eq ! ( entry. path( & file. state) , "a" ) ;
38
+
39
+ let tree = file. tree ( ) . unwrap ( ) ;
40
+ assert_eq ! ( tree. num_entries, 1 ) ;
41
+ assert_eq ! ( tree. id, hex_to_id( "496d6428b9cf92981dc9495211e6e1120fb6f2ba" ) ) ;
42
+ assert ! ( tree. name. is_empty( ) ) ;
43
+ assert ! ( tree. children. is_empty( ) ) ;
37
44
}
38
45
}
39
46
#[ test]
40
47
fn read_v2_empty ( ) {
41
48
let file = file ( "v2_empty" ) ;
42
49
assert_eq ! ( file. version( ) , Version :: V2 ) ;
43
50
assert_eq ! ( file. entries( ) . len( ) , 0 ) ;
51
+ let tree = file. tree ( ) . unwrap ( ) ;
52
+ assert_eq ! ( tree. num_entries, 0 ) ;
53
+ assert ! ( tree. name. is_empty( ) ) ;
54
+ assert ! ( tree. children. is_empty( ) ) ;
55
+ assert_eq ! ( tree. id, hex_to_id( "4b825dc642cb6eb9a060e54bf8d69288fbee4904" ) ) ;
44
56
}
45
57
46
58
#[ test]
@@ -56,6 +68,17 @@ mod init {
56
68
assert_eq ! ( e. mode, entry:: Mode :: FILE ) ;
57
69
assert_eq ! ( e. id, hex_to_id( "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391" ) )
58
70
}
71
+
72
+ let tree = file. tree ( ) . unwrap ( ) ;
73
+ assert_eq ! ( tree. id, hex_to_id( "c9b29c3168d8e677450cc650238b23d9390801fb" ) ) ;
74
+ assert_eq ! ( tree. num_entries, 6 ) ;
75
+ assert ! ( tree. name. is_empty( ) ) ;
76
+ assert_eq ! ( tree. children. len( ) , 1 ) ;
77
+
78
+ let tree = & tree. children [ 0 ] ;
79
+ assert_eq ! ( tree. id, hex_to_id( "765b32c65d38f04c4f287abda055818ec0f26912" ) ) ;
80
+ assert_eq ! ( tree. num_entries, 3 ) ;
81
+ assert_eq ! ( tree. name. as_bstr( ) , "d" ) ;
59
82
}
60
83
61
84
fn find_shared_index_for ( index : impl AsRef < Path > ) -> PathBuf {
0 commit comments