]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/cgi.t
t/cgi.t: eliminate some cruft and unnecessary tests
[public-inbox.git] / t / cgi.t
diff --git a/t/cgi.t b/t/cgi.t
index ef32a2845fee9f99a13d72c4ab093af17d48d1bc..ac2c69fc8425485525e92f91ae81e90d0849eda4 100644 (file)
--- a/t/cgi.t
+++ b/t/cgi.t
@@ -48,9 +48,8 @@ my $im = PublicInbox::Import->new($git, 'test', $addr);
 {
        local $ENV{HOME} = $home;
 
-       # ensure successful message delivery
-       {
-               my $mime = Email::MIME->new(<<EOF);
+       # inject some messages:
+       my $mime = Email::MIME->new(<<EOF);
 From: Me <me\@example.com>
 To: You <you\@example.com>
 Cc: $addr
@@ -60,15 +59,10 @@ Date: Thu, 01 Jan 1970 00:00:00 +0000
 
 zzzzzz
 EOF
-               $im->add($mime);
-               $im->done;
-               my $rev = `git --git-dir=$maindir rev-list HEAD`;
-               like($rev, qr/\A[a-f0-9]{40}/, "good revision committed");
-       }
+       $im->add($mime);
 
        # deliver a reply, too
-       {
-               my $reply = Email::MIME->new(<<EOF);
+       my $reply = Email::MIME->new(<<EOF);
 From: You <you\@example.com>
 To: Me <me\@example.com>
 Cc: $addr
@@ -82,12 +76,8 @@ Me wrote:
 
 what?
 EOF
-               $im->add($reply);
-               $im->done;
-               my $rev = `git --git-dir=$maindir rev-list HEAD`;
-               like($rev, qr/\A[a-f0-9]{40}/, "good revision committed");
-       }
-
+       $im->add($reply);
+       $im->done;
 }
 
 # obvious failures, first
@@ -118,7 +108,7 @@ EOF
        like($res->{head}, qr/Status:\s*206/i, "info/refs partial past end OK");
        is($res->{body}, substr($orig, 5), 'partial body OK past end');
 }
-use Data::Dumper;
+
 # atom feeds
 {
        local $ENV{HOME} = $home;
@@ -155,22 +145,16 @@ EOF
        $res = cgi_run("/test/blahblah\@example.com/raw");
        like($res->{body}, qr/Message-Id: <blahblah\@example\.com>/,
                "mid raw hit");
-       $res = cgi_run("/test/blahblah\@example.con/raw");
-       like($res->{head}, qr/Status: 300 Multiple Choices/, "mid raw miss");
 
        $res = cgi_run("/test/blahblah\@example.com/");
        like($res->{body}, qr/\A<html>/, "mid html hit");
        like($res->{head}, qr/Status: 200 OK/, "200 response");
-       $res = cgi_run("/test/blahblah\@example.con/");
-       like($res->{head}, qr/Status: 300 Multiple Choices/, "mid html miss");
 
        $res = cgi_run("/test/blahblah\@example.com/f/");
        like($res->{head}, qr/Status: 301 Moved/, "301 response");
        like($res->{head},
                qr!^Location: http://[^/]+/test/blahblah\@example\.com/\r\n!ms,
                '301 redirect location');
-       $res = cgi_run("/test/blahblah\@example.con/");
-       like($res->{head}, qr/Status: 300 Multiple Choices/, "mid html miss");
 
        $res = cgi_run("/test/new.html");
        like($res->{body}, qr/slashy%2Fasdf\@example\.com/,
@@ -223,14 +207,15 @@ done_testing();
 
 sub run_with_env {
        my ($env, @args) = @_;
-       my $init = sub { foreach my $k (keys %$env) { $ENV{$k} = $env->{$k} } };
-       IPC::Run::run(@args, init => $init);
+       IPC::Run::run(@args, init => sub { %ENV = (%ENV, %$env) });
 }
 
 sub cgi_run {
        my %env = (
                PATH_INFO => $_[0],
                QUERY_STRING => $_[1] || "",
+               SCRIPT_NAME => '',
+               REQUEST_URI => $_[0] . ($_[1] ? "?$_[1]" : ''),
                REQUEST_METHOD => $_[2] || "GET",
                GATEWAY_INTERFACE => 'CGI/1.1',
                HTTP_ACCEPT => '*/*',