test md5_get and create foo.txt if needed
authorDobrica Pavlinusic <dpavlin@rsync1.maxxo.com>
Wed, 16 May 2012 17:54:15 +0000 (19:54 +0200)
committerDobrica Pavlinusic <dpavlin@rsync1.maxxo.com>
Wed, 16 May 2012 17:54:15 +0000 (19:54 +0200)
t/Gearman.t

index c2df62f..ab170dc 100755 (executable)
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 55;
+use Test::More tests => 56;
 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,7 +56,16 @@ 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");
+}
+
+gearman( 'md5_get' => "~$u1/foo.txt" );
 
 gearman send_file => "~$u1/foo.txt#~$u2/dir with space/file with space";
 test_refresh_file_list "$u2";