X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fpsgi_v2.t;h=6b1b3a39bd7f29f5656482aae6ed30dc9cb8b592;hb=d6aa79dcb15bb78f5ed6cb3c0d8d209b4e9e9064;hp=1f19070894571eef0dea0650b06e4718016ea775;hpb=be940983157a1f8bd353cb1891f6971645c73e5d;p=public-inbox.git
diff --git a/t/psgi_v2.t b/t/psgi_v2.t
index 1f190708..6b1b3a39 100644
--- a/t/psgi_v2.t
+++ b/t/psgi_v2.t
@@ -1,5 +1,5 @@
#!perl -w
-# Copyright (C) 2018-2021 all contributors
+# Copyright (C) all contributors
# License: AGPL-3.0+
use strict;
use v5.10.1;
@@ -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();
@@ -20,11 +20,12 @@ To: test@example.com
Subject: this is a subject
Message-ID:
Date: Fri, 02 Oct 1993 00:00:00 +0000
+Content-Type: text/plain; charset=iso-8859-1
hello world
EOF
my $new_mid;
-my $ibx = create_inbox 'v2', version => 2, indexlevel => 'medium',
+my $ibx = create_inbox 'v2-1', version => 2, indexlevel => 'medium',
tmpdir => "$tmpdir/v2", sub {
my ($im, $ibx) = @_;
$im->add($eml) or BAIL_OUT;
@@ -68,6 +69,8 @@ my $client0 = sub {
like($res->content, qr!\$INBOX_DIR/description missing!,
'got v2 description missing message');
$res = $cb->(GET('/v2test/a-mid@b/raw'));
+ is($res->header('Content-Type'), 'text/plain; charset=iso-8859-1',
+ 'charset from message used');
$raw = $res->content;
unlike($raw, qr/^From oldbug/sm, 'buggy "From_" line omitted');
like($raw, qr/^hello world$/m, 'got first message');
@@ -92,6 +95,11 @@ 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);
my $env = { TMPDIR => $tmpdir, PI_CONFIG => $cfgpath };
@@ -113,6 +121,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');
@@ -193,6 +209,8 @@ my $client1 = sub {
local $SIG{__WARN__} = 'DEFAULT';
$res = $cb->(GET('/v2test/a-mid@b/'));
$raw = $res->content;
+ like($raw, qr/WARNING: multiple messages have this Message-ID/,
+ 'warned about duplicate Message-IDs');
like($raw, qr/^hello world$/m, 'got first message');
like($raw, qr/^hello world!$/m, 'got second message');
like($raw, qr/^hello ghosts$/m, 'got third message');