@@ -448,6 +448,10 @@ async fn test_chroot() {
448
448
let cluster = format ! ( "127.0.0.1:{}" , zk_port) ;
449
449
let client = zk:: Client :: connect ( & cluster) . await . unwrap ( ) ;
450
450
451
+ assert_eq ! ( client. path( ) , "/" ) ;
452
+ let client = client. chroot ( "abc" ) . unwrap_err ( ) ;
453
+ assert_eq ! ( client. path( ) , "/" ) ;
454
+
451
455
let path = "/abc" ;
452
456
let data = random_data ( ) ;
453
457
let child_path = "/abc/efg" ;
@@ -458,13 +462,18 @@ async fn test_chroot() {
458
462
let ( stat, _) = client. create ( path, & data, & create_options) . await . unwrap ( ) ;
459
463
460
464
let path_client = client. clone ( ) . chroot ( path) . unwrap ( ) ;
465
+ assert_eq ! ( path_client. path( ) , path) ;
461
466
assert_eq ! ( ( data, stat) , path_client. get_data( "/" ) . await . unwrap( ) ) ;
462
467
463
468
let relative_child_path = child_path. strip_prefix ( path) . unwrap ( ) ;
464
469
let ( child_stat, _) = path_client. create ( relative_child_path, & child_data, & create_options) . await . unwrap ( ) ;
465
470
assert_eq ! ( ( child_data. clone( ) , child_stat) , path_client. get_data( relative_child_path) . await . unwrap( ) ) ;
466
471
assert_eq ! ( ( child_data. clone( ) , child_stat) , client. get_data( child_path) . await . unwrap( ) ) ;
467
472
473
+ let child_client = client. clone ( ) . chroot ( child_path. to_string ( ) ) . unwrap ( ) ;
474
+ assert_eq ! ( child_client. path( ) , child_path) ;
475
+ assert_eq ! ( ( child_data. clone( ) , child_stat) , child_client. get_data( "/" ) . await . unwrap( ) ) ;
476
+
468
477
let relative_grandchild_path = grandchild_path. strip_prefix ( path) . unwrap ( ) ;
469
478
let ( _, grandchild_watcher) = client. check_and_watch_stat ( grandchild_path) . await . unwrap ( ) ;
470
479
let ( _, relative_grandchild_watcher) = path_client. check_and_watch_stat ( relative_grandchild_path) . await . unwrap ( ) ;
0 commit comments