test file_size with send to different shard
[cloudstore.git] / t / Store.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use Test::More tests => 12;
6 use Data::Dump qw(dump);
7
8 use lib 'lib';
9
10 use_ok 'CloudStore::Store';
11
12 my $data =
13 {
14   file       => "test/store",
15   itemize    => ">f+++++++++",
16   login      => "u2001",
17   md5        => "d8e8fca2dc0f896fd7cb4cb0031ba249",
18   mtime      => "2011-07-17T17:55:15",
19   op         => "recv",
20   perms      => "rw-r--r--",
21   pid        => 29525,
22   port       => 6501,
23   size       => 10024,
24   timestamp  => "2011-07-17T17:55:15",
25   transfered => 10064,
26 };
27
28 ok my $r = CloudStore::Store->new('s1'), 'new';
29
30 ok my $u = $r->{api}->user_info('u2001'), 'user_info';
31
32 ok $r->init_pid_login( $data->{pid}, $data->{login} ), 'init_pid_login';
33
34 ok my $full_path = $r->blob_path( $data ), 'blob_path';
35 diag $full_path;
36
37 if ( ! -e $full_path ) {
38         $r->{api}->mkbasepath( $full_path, { uid => $u->{uid} } );
39         open(my $fh, '>', $full_path) || die $!;
40         print $fh "test\n" || die $!;
41         close $fh;
42         diag "$full_path created";
43         chown $u->{uid}, $u->{gid}, $full_path;
44 }
45
46 ok my $d = $r->rsync_transfer($data), 'rsync_transfer';
47 diag dump($d);
48
49 ok unlink($full_path), 'unlink';
50 ok $r->removed_file($data), 'removed_file';
51
52 ok $r->api->rename_file( $u, 'test' => 'test2' ), 'rename_file';
53
54 ok $r->{api}->delete( $u => 'test2' ), 'delete';
55
56 $data->{file} = 'md5sum';
57 ok $r->rsync_transfer($data), 'rsync_transfer md5sum';
58
59 ok $r->cleanup_pid( $data->{pid} ), 'cleanup_pid';
60