5 use Test::More tests => 35;
6 use Data::Dump qw(dump);
10 use_ok 'CloudStore::Gearman';
12 my $hostname = `hostname -s`;
15 my $user = $ARGV[0] || 2001;
18 my ( $function, $args ) = @_;
19 ok( my $o = CloudStore::Gearman->gearman_do( @_ ), join(' ',@_) );
26 CloudStore::Gearman->gearman_do( file_size => $file );
29 sub test_refresh_file_list {
31 ok ! file_exists( "~$login/.meta/files" ), "refresh_file_list removed .meta/files";
32 gearman list_files => "~$login";
35 my $o = gearman $hostname . '_s1_quota_get' => $user;
37 cmp_ok $o, '=~', qr/^(\d+)\s+(\d+)$/, 'format: used quota';
39 gearman( 'user_usage' => $user );
41 gearman( $hostname . '_s1_torrent_list' );
43 diag "create .meta/files if it doesn't exist";
44 foreach my $uid ( 2001, 2002 ) {
45 gearman list_files => "~u$uid";
46 ok file_exists "~u$uid/.meta/files", "file_exists ~u$uid/.meta/files";
49 file_exists '~u2001/foo.txt' || BAIL_OUT("~u2001/foo.txt is required for rest of tests");
51 gearman send_file => '~u2001/foo.txt#~u2002/dir with space/file with space';
52 test_refresh_file_list 'u2002';
54 gearman delete => '~u2002/dir with space/file with space';
55 test_refresh_file_list 'u2002';
57 gearman send_file => '~u2001/foo.txt#~u2002/foo.txt';
58 test_refresh_file_list 'u2002';
60 gearman rename_file => '~u2002/foo.txt#bar.txt';
61 test_refresh_file_list 'u2002';
62 gearman rename_file => '~u2002/bar.txt#baz.txt';
63 test_refresh_file_list 'u2002';
66 gearman( file_size => '~u2001/foo.txt' ), '==',
67 gearman( file_size => '~u2002/baz.txt' ), 'size_same';
69 diag "test symlink to other shard";
70 gearman send_file => '~u2001/foo.txt#~u2004/foo.txt';
71 my $size_1 = gearman( file_size => '~u2001/foo.txt' );
72 my $size_2 = gearman( file_size => '~u2004/foo.txt' );
74 cmp_ok $size_1, '==', $size_2, 'symlink size same';
76 gearman delete => '~u2002/baz.txt';
77 test_refresh_file_list 'u2002';
79 ok ! CloudStore::Gearman->gearman_do( file_size => '~u2002/baz.txt' ), 'deleted file size';