@@ -41,6 +41,13 @@ fn test_directory() {
4141 futures:: executor:: block_on ( test_list ( & db, & directory, vec ! [ String :: from( "a" ) ] , 10 ) )
4242 . expect ( "failed to run" ) ;
4343
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+
4451 futures:: executor:: block_on ( test_bad_layer ( & db) ) . expect ( "failed to run" ) ;
4552}
4653
@@ -76,6 +83,7 @@ async fn test_create_or_open_async(
7683 Ok ( ( ) )
7784}
7885
86+ /// testing that we throwing Err(DirectoryError::IncompatibleLayer)
7987async fn test_bad_layer ( db : & Database ) -> Result < ( ) , DirectoryError > {
8088 let directory = DirectoryLayer {
8189 layer : vec ! [ 0u8 ] ,
@@ -103,6 +111,7 @@ async fn test_bad_layer(db: &Database) -> Result<(), DirectoryError> {
103111 Ok ( ( ) )
104112}
105113
114+ /// testing list functionality. Will open paths and create n sub-folders.
106115async fn test_list (
107116 db : & Database ,
108117 directory : & DirectoryLayer ,
@@ -145,3 +154,40 @@ async fn test_list(
145154
146155 Ok ( ( ) )
147156}
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