X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=t%2FAPI.t;h=4f81d1f25489cb03cd8cf6c8b60f05357e843f38;hb=3b458e4db1acf5a7f200f38d629bed9f38632abd;hp=0b31f9c805256a37faf6bcf637a7ecd19eff2fd1;hpb=bfab7a952b5a81832822807b0bdb818af19924cd;p=cloudstore.git diff --git a/t/API.t b/t/API.t index 0b31f9c..4f81d1f 100755 --- a/t/API.t +++ b/t/API.t @@ -2,8 +2,9 @@ use strict; use warnings; -use Test::More tests => 27; +use Test::More tests => 29; use Data::Dump qw(dump); +use File::Path; use lib 'lib'; @@ -11,9 +12,9 @@ use_ok 'CloudStore::API'; ok my $o = CloudStore::API->new('s1'), 'new'; -ok exists $o->{SLICE}, 'SLICE'; +die 'You need to run this test as root' unless $> == 0; -cmp_ok $o->create_user('md5@example.com','md5sum',0), '==', 2000, 'create_user md5'; +cmp_ok $o->create_user('md5@example.com','md5sum',0), 'eq', 'u2000', 'create_user md5'; ok my $info = $o->user_info( 'md5' ), 'user_info'; diag dump $info; @@ -62,3 +63,15 @@ usage $uid2; ok $o->delete( $uid, 'bar.txt' ); usage $uid; +my $path = "/tmp/test.$$/base/dir/path"; +ok $o->mkbasepath( $path, { uid => $info->{uid} } ), "mkbasepath $path"; + +ok ! $o->mkbasepath( $path, { uid => $info->{uid} } ), "exists $path"; + +$path =~ s{/path}{}; # strip file +my $uid = (stat($path))[4]; +diag "uid $path = $uid"; +cmp_ok $uid, '==', $info->{uid}, "owner $info->{uid}"; + +File::Path::remove_tree("/tmp/test.$$"); # cleanup +