]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/cgi.t
wire up shorter, less ambiguous URLs
[public-inbox.git] / t / cgi.t
diff --git a/t/cgi.t b/t/cgi.t
index a16ebd8daa5485f57eb3b3647655f23794fd2506..020dfe7eeea81c6c9d92de6e28f8d4c6ab08b5d6 100644 (file)
--- a/t/cgi.t
+++ b/t/cgi.t
@@ -10,6 +10,7 @@ use IPC::Run qw/run/;
 
 use constant CGI => "blib/script/public-inbox.cgi";
 my $mda = "blib/script/public-inbox-mda";
+my $index = "blib/script/public-inbox-index";
 my $tmpdir = tempdir(CLEANUP => 1);
 my $home = "$tmpdir/pi-home";
 my $pi_home = "$home/.public-inbox";
@@ -178,6 +179,29 @@ EOF
                "slashy URL generated correctly");
 }
 
+# retrieve thread as an mbox
+{
+       local $ENV{HOME} = $home;
+       local $ENV{PATH} = $main_path;
+       my $path = "/test/t/blahblah%40example.com/mbox.gz";
+       my $res = cgi_run($path);
+       like($res->{head}, qr/^Status: 501 /, "search not-yet-enabled");
+       my $indexed = system($index, $maindir) == 0;
+       if ($indexed) {
+               $res = cgi_run($path);
+               like($res->{head}, qr/^Status: 200 /, "search returned mbox");
+               eval {
+                       require IO::Uncompress::Gunzip;
+                       my $in = $res->{body};
+                       my $out;
+                       IO::Uncompress::Gunzip::gunzip(\$in => \$out);
+                       like($out, qr/^From /m, "From lines in mbox");
+               };
+       } else {
+               like($res->{head}, qr/^Status: 501 /, "search not available");
+       }
+}
+
 # redirect list-name-only URLs
 {
        local $ENV{HOME} = $home;