X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fpsgi_v2.t;h=64c1a8d38a0a5b842568657bde03d71175ec17a3;hb=b5454f38b1903735594e3c253617a66dd267062f;hp=487317b6134046d3a98b80a6caa3f5cf5bb38e8f;hpb=0e3e45d785ed85c2a2802fa6b2440d8f3e966531;p=public-inbox.git
diff --git a/t/psgi_v2.t b/t/psgi_v2.t
index 487317b6..64c1a8d3 100644
--- a/t/psgi_v2.t
+++ b/t/psgi_v2.t
@@ -9,7 +9,7 @@ use PublicInbox::Eml;
use PublicInbox::Config;
use PublicInbox::MID qw(mids);
require_mods(qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test
- URI::Escape Plack::Builder));
+ URI::Escape Plack::Builder HTTP::Date));
use_ok($_) for (qw(HTTP::Request::Common Plack::Test));
use_ok 'PublicInbox::WWW';
my ($tmpdir, $for_destroy) = tmpdir();
@@ -56,27 +56,6 @@ EOF
close $fh or BAIL_OUT;
}
-my $run_httpd = sub {
- my ($client, $skip) = @_;
- SKIP: {
- require_mods(qw(Plack::Test::ExternalServer), $skip);
- my $env = { PI_CONFIG => $cfgpath };
- my $sock = tcp_server() or die;
- my ($out, $err) = map { "$tmpdir/std$_.log" } qw(out err);
- my $cmd = [ qw(-httpd -W0), "--stdout=$out", "--stderr=$err" ];
- my $td = start_script($cmd, $env, { 3 => $sock });
- my ($h, $p) = tcp_host_port($sock);
- local $ENV{PLACK_TEST_EXTERNALSERVER_URI} = "http://$h:$p";
- Plack::Test::ExternalServer::test_psgi(client => $client);
- $td->join('TERM');
- open my $fh, '<', $err or BAIL_OUT $!;
- my $e = do { local $/; <$fh> };
- if ($e =~ s/^Plack::Middleware::ReverseProxy missing,\n//gms) {
- $e =~ s/^URL generation for redirects .*\n//gms;
- }
- is($e, '', 'no errors');
- }
-};
my $msg = $ibx->msg_by_mid('a-mid@b');
like($$msg, qr/\AFrom oldbug/s,
'"From_" line stored to test old bug workaround');
@@ -113,9 +92,15 @@ my $client0 = sub {
@bodies = ($res->content =~ /^(hello [^<]+)$/mg);
is_deeply(\@bodies, [ "hello world!\n", "hello world\n" ],
'new.html ordering is chronological');
+
+ $res = $cb->(GET('/v2test/new.atom'));
+ my @dates = ($res->content =~ m!title>([^<]+)!g);
+ is_deeply(\@dates, [ "1993-10-02T00:01:00Z", "1993-10-02T00:00:00Z" ],
+ 'Date headers made it through');
};
test_psgi(sub { $www->call(@_) }, $client0);
-$run_httpd->($client0, 9);
+my $env = { TMPDIR => $tmpdir, PI_CONFIG => $cfgpath };
+test_httpd($env, $client0, 9);
$eml->header_set('Message-ID', 'a-mid@b');
$eml->body_set("hello ghosts\n");
@@ -133,6 +118,14 @@ $im->done;
my $client1 = sub {
my ($cb) = @_;
+ $res = $cb->(GET('/v2test/_/text/config/raw'));
+ my $lm = $res->header('Last-Modified');
+ ok($lm, 'Last-Modified set w/ ->mm');
+ $lm = HTTP::Date::str2time($lm);
+ is($lm, $ibx->mm->created_at,
+ 'Last-Modified for text/config/raw matches ->created_at');
+ delete $ibx->{mm};
+
$res = $cb->(GET("/v2test/$third/raw"));
$raw = $res->content;
like($raw, qr/^hello ghosts$/m, 'got third message');
@@ -225,7 +218,7 @@ my $client1 = sub {
};
test_psgi(sub { $www->call(@_) }, $client1);
-$run_httpd->($client1, 38);
+test_httpd($env, $client1, 38);
{
my $exp = [ qw( ) ];
@@ -267,7 +260,7 @@ my $client2 = sub {
};
test_psgi(sub { $www->call(@_) }, $client2);
-$run_httpd->($client2, 8);
+test_httpd($env, $client2, 8);
{
# ensure conflicted attachments can be resolved
local $SIG{__WARN__} = sub {};
@@ -298,6 +291,6 @@ my $client3 = sub {
is_deeply(\@warn, [], 'no warnings on YYYYMMDD only');
};
test_psgi(sub { $www->call(@_) }, $client3);
-$run_httpd->($client3, 4);
+test_httpd($env, $client3, 4);
done_testing;