X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=t%2FGearman.t;h=c344dd681642d070ce869f5a4d0a2a969d9bcce0;hb=8fa0beca9e4ecba63a26a3b97d9319cc9a72c3ef;hp=00dc305ab43805a71c8aec51d95aaab7afdab40b;hpb=af7712586a0c3d0a1c4e9d1fa468c2d11498d768;p=cloudstore.git diff --git a/t/Gearman.t b/t/Gearman.t index 00dc305..c344dd6 100755 --- a/t/Gearman.t +++ b/t/Gearman.t @@ -2,7 +2,7 @@ use strict; use warnings; -use Test::More tests => 47; +use Test::More tests => 60; use Data::Dump qw(dump); use lib 'lib'; @@ -11,6 +11,7 @@ use_ok 'CloudStore::Gearman'; my $hostname = `hostname -s`; chomp $hostname; +$hostname =~ s/-dev// && warn "# fix hostname for development"; sub gearman { my ( $function, $args ) = @_; @@ -55,14 +56,37 @@ foreach my $login ( $u1, $u2 ) { ok file_exists "~$login/.meta/files", "file_exists ~$login/.meta/files"; } -file_exists "~$u1/foo.txt" || BAIL_OUT("~$u1/foo.txt is required for rest of tests"); +if ( ! file_exists("~$u1/foo.txt") ) { + diag "create ~$u1/foo.txt"; + $ENV{RSYNC_PASSWORD} ||= 'secret'; + system('rsync', '-vv', $0, "rsync://$u1\@127.0.0.1:6501/$u1/" ); + gearman rename_file => "~$u1/Gearman.t#foo.txt"; +} else { + file_exists("~$u1/foo.txt") || BAIL_OUT("~$u1/foo.txt is required for rest of tests"); +} + +my $md5 = gearman( 'md5_get' => "~$u1/foo.txt" ); +diag "md5_get = $md5"; gearman send_file => "~$u1/foo.txt#~$u2/dir with space/file with space"; test_refresh_file_list "$u2"; +cmp_ok gearman( 'md5_get' => "~$u2/dir with space/file with space" ), 'eq', $md5, "md5_get on send_file to $u2"; + +my $files = gearman list_files => "~$u2"; +like $files, qr|dir with space/file with space|, 'found sent file in list_files'; + +gearman send_file => "~$u2/dir with space/file with space#~$u3/another dir with spaces/and file with spaces"; +test_refresh_file_list "$u3"; + +cmp_ok gearman( 'md5_get' => "~$u3/another dir with spaces/and file with spaces" ), 'eq', $md5, "md5_get on send_file to $u3"; + gearman delete => "~$u2/dir with space/file with space"; test_refresh_file_list "$u2"; +gearman delete => "~$u3/another dir with spaces/and file with spaces"; +test_refresh_file_list "$u3"; + gearman send_file => "~$u1/foo.txt#~$u2/foo.txt"; test_refresh_file_list "$u2";