my ($tmpdir, $for_destroy) = tmpdir();
my $http = 'http://'.tcp_host_port($sock);
my ($ro_home, $cfg_path) = setup_public_inboxes;
-my $cmd = [ qw(-httpd -W0), "--stdout=$tmpdir/out", "--stderr=$tmpdir/err" ];
+my $cmd = [ qw(-httpd -W0 ./t/lei-mirror.psgi),
+ "--stdout=$tmpdir/out", "--stderr=$tmpdir/err" ];
my $td = start_script($cmd, { PI_CONFIG => $cfg_path }, { 3 => $sock });
test_lei({ tmpdir => $tmpdir }, sub {
my $home = $ENV{HOME};
lei_ok('ls-external');
unlike($lei_out, qr!\Q$t2-fail\E!, 'not added to ls-external');
+ lei_ok('add-external', "$t1-pfx", '--mirror', "$http/pfx/t1/",
+ \'--mirror v1 w/ PSGI prefix');
+ ok(!-e "$t1-pfx/mirror.done", 'no leftover mirror.done');
+
+ my $d = "$home/404";
+ ok(!lei(qw(add-external --mirror), "$http/404", $d), 'mirror 404');
+ unlike($lei_err, qr!unlink.*?404/mirror\.done!,
+ 'no unlink failure message');
+ ok(!-d $d, "`404' dir not created");
+ lei_ok('ls-external');
+ unlike($lei_out, qr!\Q$d\E!s, 'not added to ls-external');
+
my %phail = (
HTTPS => 'https://public-inbox.org/' . 'phail',
ONION =>
} # for
});
+SKIP: {
+ undef $sock;
+ my $d = "$tmpdir/d";
+ mkdir $d or xbail "mkdir $d $!";
+ my $opt = { -C => $d, 2 => \(my $err) };
+ ok(!run_script([qw(-clone -q), "$http/404"], undef, $opt), '404 fails');
+ ok(!-d "$d/404", 'destination not created');
+ delete $opt->{2};
+
+ ok(run_script([qw(-clone -q -C), $d, "$http/t2"], undef, $opt),
+ '-clone succeeds on v2');
+ ok(-d "$d/t2/git/0.git", 'epoch cloned');
+ ok(-f "$d/t2/manifest.js.gz", 'manifest saved');
+ ok(!-e "$d/t2/mirror.done", 'no leftover mirror.done');
+ ok(run_script([qw(-fetch -q -C), "$d/t2"], undef, $opt),
+ '-fetch succeeds w/ manifest.js.gz');
+ unlink("$d/t2/manifest.js.gz") or xbail "unlink $!";
+ ok(run_script([qw(-fetch -q -C), "$d/t2"], undef, $opt),
+ '-fetch succeeds w/o manifest.js.gz');
+
+ ok(run_script([qw(-clone -q -C), $d, "$http/t1"], undef, $opt),
+ 'cloning v1 works');
+ ok(-d "$d/t1", 'v1 cloned');
+ ok(!-e "$d/t1/mirror.done", 'no leftover file');
+ ok(run_script([qw(-fetch -q -C), "$d/t1"], undef, $opt),
+ 'fetching v1 works');
+}
+
ok($td->kill, 'killed -httpd');
$td->join;