use strict;
use warnings;
-use Test::More tests => 47;
+use Test::More tests => 60;
use Data::Dump qw(dump);
use lib 'lib';
my $hostname = `hostname -s`;
chomp $hostname;
+$hostname =~ s/-dev// && warn "# fix hostname for development";
sub gearman {
my ( $function, $args ) = @_;
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";