]> 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 b59ca54ae15e6d96ea4683e691cd8b5256caf798..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";
@@ -120,7 +121,9 @@ EOF
        like($res->{head}, qr/Status: 200 OK/, "index returns 200");
 
        my $idx = cgi_run("/test/index.html");
-       $idx->{body} =~ s!/index.html(\?r=)!/$1!; # dirty...
+       $idx->{body} =~ s!/index.html(\?r=)!/$1!g; # dirty...
+       $idx->{body} = [ split(/\n/, $idx->{body}) ];
+       $res->{body} = [ split(/\n/, $res->{body}) ];
        is_deeply($res, $idx,
                '/$LISTNAME/ and /$LISTNAME/index.html are nearly identical');
        # more checks in t/feed.t
@@ -176,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;