X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fpsgi_v2.t;h=5b197a9f65b9d2d14d8e659bbb392f19dd7425c5;hb=bc54a149d08e9eac58a14c77b3df29fdb2f07fb8;hp=64c1a8d38a0a5b842568657bde03d71175ec17a3;hpb=45f87867107724371d80a563099ab93eda1d919b;p=public-inbox.git
diff --git a/t/psgi_v2.t b/t/psgi_v2.t
index 64c1a8d3..5b197a9f 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;
@@ -13,6 +13,36 @@ require_mods(qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test
use_ok($_) for (qw(HTTP::Request::Common Plack::Test));
use_ok 'PublicInbox::WWW';
my ($tmpdir, $for_destroy) = tmpdir();
+my $enc_dup = 'ref-20150309094050.GO3427@x1.example';
+
+my $dibx = create_inbox 'v2-dup', version => 2, indexlevel => 'medium',
+ tmpdir => "$tmpdir/dup", sub {
+ my ($im, $ibx) = @_;
+ my $common = <<"";
+Date: Mon, 9 Mar 2015 09:40:50 +0000
+From: x\@example.com
+To: y\@example.com
+Subject: re
+Message-ID: <$enc_dup>
+MIME-Version: 1.0
+
+ $im->add(PublicInbox::Eml->new($common.<add(PublicInbox::Eml->new($common.<new(<<'EOF');
From oldbug-pre-a0c07cba0e5d8b6a Fri Oct 2 00:00:00 1993
From: a@example.com
@@ -20,11 +50,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;
@@ -52,6 +83,9 @@ my $cfgpath = "$ibx->{inboxdir}/pi_config";
[publicinbox "v2test"]
inboxdir = $ibx->{inboxdir}
address = $ibx->{-primary_address}
+[publicinbox "dup"]
+ inboxdir = $dibx->{inboxdir}
+ address = $dibx->{-primary_address}
EOF
close $fh or BAIL_OUT;
}
@@ -68,6 +102,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');
@@ -206,6 +242,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');
@@ -215,6 +253,14 @@ my $client1 = sub {
like($raw, qr!>\Q$mid\E!s, "Message-ID $mid shown");
}
like($raw, qr/\b3\+ messages\b/, 'thread overview shown');
+
+ $res = $cb->(GET("/dup/$enc_dup/d/"));
+ is($res->code, 200, '/d/ (diff) endpoint works');
+ $raw = $res->content;
+ like($raw, qr! cr_mismatch\n!s,
+ 'cr_mismatch is only diff context');
+ like($raw, qr!>\-pipe !s, 'pipe diff del line');
+ like($raw, qr!>\+pipe !s, 'pipe diff ins line');
};
test_psgi(sub { $www->call(@_) }, $client1);