migrate test-gearman.sh into test
[cloudstore.git] / t / Gearman.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use Test::More tests => 11;
6 use Data::Dump qw(dump);
7
8 use lib 'lib';
9
10 use_ok 'CloudStore::Gearman';
11
12 my $hostname = `hostname -s`;
13 chomp $hostname;
14
15 my $user = $ARGV[0] || 2001;
16
17 sub gearman {
18         my ( $function, $args ) = @_;
19         ok my $o = CloudStore::Gearman->gearman_do( @_ ), $_[0];
20         diag dump $o;
21         return $o;
22 }
23
24 my $o = gearman $hostname . '_s1_quota_get' => $user;
25 diag dump $o;
26 cmp_ok $o, '=~', qr/^(\d+)\s+(\d+)$/, 'format: used quota';
27
28 gearman( 'user_usage' => $user );
29
30 gearman( $hostname . '_s1_torrent_list' );
31
32
33 gearman send_file => '~u2001/foo.txt#~u2002/dir with space/file with space';
34
35 gearman delete => '~u2002/dir with space/file with space';
36
37 gearman send_file => '~u2001/foo.txt#~u2002/foo.txt';
38
39 gearman rename_file => '~u2002/foo.txt#bar.txt';
40 gearman rename_file => '~u2002/bar.txt#baz.txt';
41
42 gearman delete => '~u2002/baz.txt';
43