@@ -41,6 +41,13 @@ fn test_directory() {
41
41
futures:: executor:: block_on ( test_list ( & db, & directory, vec ! [ String :: from( "a" ) ] , 10 ) )
42
42
. expect ( "failed to run" ) ;
43
43
44
+ futures:: executor:: block_on ( test_children_content_subspace (
45
+ & db,
46
+ & directory,
47
+ vec ! [ String :: from( "c" ) ] ,
48
+ ) )
49
+ . expect ( "failed to run" ) ;
50
+
44
51
futures:: executor:: block_on ( test_bad_layer ( & db) ) . expect ( "failed to run" ) ;
45
52
}
46
53
@@ -76,6 +83,7 @@ async fn test_create_or_open_async(
76
83
Ok ( ( ) )
77
84
}
78
85
86
+ /// testing that we throwing Err(DirectoryError::IncompatibleLayer)
79
87
async fn test_bad_layer ( db : & Database ) -> Result < ( ) , DirectoryError > {
80
88
let directory = DirectoryLayer {
81
89
layer : vec ! [ 0u8 ] ,
@@ -103,6 +111,7 @@ async fn test_bad_layer(db: &Database) -> Result<(), DirectoryError> {
103
111
Ok ( ( ) )
104
112
}
105
113
114
+ /// testing list functionality. Will open paths and create n sub-folders.
106
115
async fn test_list (
107
116
db : & Database ,
108
117
directory : & DirectoryLayer ,
@@ -145,3 +154,40 @@ async fn test_list(
145
154
146
155
Ok ( ( ) )
147
156
}
157
+
158
+ /// checks that the content_subspace of the children is inside the parent
159
+ async fn test_children_content_subspace (
160
+ db : & Database ,
161
+ directory : & DirectoryLayer ,
162
+ paths : Vec < String > ,
163
+ ) -> Result < ( ) , DirectoryError > {
164
+ let trx = db. create_trx ( ) ?;
165
+
166
+ eprintln ! ( "parent = {:?}" , paths. to_owned( ) ) ;
167
+
168
+ let root_subspace = directory. create_or_open ( & trx, paths. to_owned ( ) ) . await ?;
169
+
170
+ let mut children_path = paths. clone ( ) ;
171
+ children_path. push ( String :: from ( "nested" ) ) ;
172
+ eprintln ! ( "children = {:?}" , children_path. to_owned( ) ) ;
173
+
174
+ let children_subspace = directory
175
+ . create_or_open ( & trx, children_path. to_owned ( ) )
176
+ . await ?;
177
+
178
+ assert ! (
179
+ children_subspace. bytes( ) . starts_with( root_subspace. bytes( ) ) ,
180
+ "children subspace '{:?} does not start with parent subspace '{:?}'" ,
181
+ children_subspace. bytes( ) ,
182
+ root_subspace. bytes( )
183
+ ) ;
184
+
185
+ trx. commit ( ) . await . expect ( "could not commit" ) ;
186
+ let trx = db. create_trx ( ) ?;
187
+
188
+ let open_children_subspace = directory. open ( & trx, children_path. to_owned ( ) ) . await ?;
189
+
190
+ assert_eq ! ( children_subspace. bytes( ) , open_children_subspace. bytes( ) ) ;
191
+
192
+ Ok ( ( ) )
193
+ }
0 commit comments