]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/lei-mirror.t
lei: fix handling of broken lei.saved-search config files
[public-inbox.git] / t / lei-mirror.t
index dfd35e1af5cae6a1866b64ae24d1c35d32c33575..a61a756596fc5b6c14d4db511c37664108af62eb 100644 (file)
@@ -7,7 +7,8 @@ my $sock = tcp_server();
 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};
@@ -27,6 +28,7 @@ test_lei({ tmpdir => $tmpdir }, sub {
 
        ok(!lei('add-external', $t2, '--mirror', "$http/t2/"),
                '--mirror fails if reused') or diag "$lei_err.$lei_out = $?";
+       like($lei_err, qr/\Q$t2\E' already exists/, 'destination in error');
 
        ok(!lei('add-external', "$home/t2\nnewline", '--mirror', "$http/t2/"),
                '--mirror fails on newline');
@@ -37,13 +39,27 @@ test_lei({ tmpdir => $tmpdir }, sub {
        unlike($lei_out, qr!\Qnewline\E!, 'newline entry not added');
 
        ok(!lei('add-external', "$t2-fail", '-Lmedium'), '--mirror v2');
+       like($lei_err, qr/not a directory/, 'non-directory noted');
        ok(!-d "$t2-fail", 'destination not created on failure');
        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');
+
+       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 => 'http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/' . 'phail,'
+               ONION =>
+'http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/' .
+'phail,'
        );
        for my $t (qw(HTTPS ONION)) {
        SKIP: {
@@ -56,6 +72,7 @@ test_lei({ tmpdir => $tmpdir }, sub {
                is($? >> 8, 22, 'curl 404');
                ok(!-d $dir, 'directory not created');
                unlike($lei_err, qr/# mirrored/, 'no success message');
+               like($lei_err, qr/curl.*404/, "curl 404 shown for $k");
        } # SKIP
        } # for
 });