test file_size with send to different shard
[cloudstore.git] / t / API.t
diff --git a/t/API.t b/t/API.t
index 58eb691..0b31f9c 100755 (executable)
--- a/t/API.t
+++ b/t/API.t
@@ -2,17 +2,16 @@
 use strict;
 use warnings;
 
-use Test::More tests => 17;
+use Test::More tests => 27;
 use Data::Dump qw(dump);
 
 use lib 'lib';
 
 use_ok 'CloudStore::API';
 
-$ENV{PORT}=6500;
-$ENV{SLICE}='/tmp/';
+ok my $o = CloudStore::API->new('s1'), 'new';
 
-ok my $o = CloudStore::API->new, 'new';
+ok exists $o->{SLICE}, 'SLICE';
 
 cmp_ok $o->create_user('md5@example.com','md5sum',0), '==', 2000, 'create_user md5';
 
@@ -32,14 +31,34 @@ ok close($fh) , 'close';
 ok chown $test->{uid}, $test->{gid}, "$test->{dir}/foo.txt", 'chown';
 
 ok my $uid2 = $o->create_user('test2@example.com','password',100_000_000), 'create_user test2';
+ok my $test2 = $o->user_info( $uid2 ), "user_info $uid2";
+
+foreach ( $test->{dir}, $test2->{dir} ) {
+       $_ .= "/.log";
+       unlink $_ if -e $_;
+}
+
+sub usage {
+       ok my $u = $o->usage( $_[0] ), 'usage';
+#      diag dump $u;
+}
 
 ok $o->send_file( $uid => '/foo.txt', $uid2 => 'dir1/dir2/bar.txt' ), 'send_file';
+usage $uid;
+usage $uid2;
 
 ok $o->send_file( $uid2 => 'dir1/dir2/bar.txt', $uid => 'bar.txt' ), 'send_file back';
+usage $uid;
+usage $uid2;
+
+ok $o->send_file( $uid2 => 'dir1/dir2/bar.txt', 2004 => 'bar.txt' ), 'send_file cross-slice';
 
 ok $o->delete( $uid, 'foo.txt' );
+usage $uid;
 
 ok $o->delete( $uid2, 'dir1' );
+usage $uid2;
 
 ok $o->delete( $uid, 'bar.txt' );
+usage $uid;