-use_ok 'PublicInbox::V2Writable';
-my ($inboxdir, $for_destroy) = tmpdir();
-my $cfgpath = "$inboxdir/$$.config";
-SKIP: {
- require_mods(qw(Plack::Test::ExternalServer), 1);
- open my $fh, '>', $cfgpath or BAIL_OUT $!;
- print $fh <<EOF or BAIL_OUT $!;
-[publicinbox "v2test"]
- inboxdir = $inboxdir
- address = test\@example.com
-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 { "$inboxdir/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) = ($sock->sockhost, $sock->sockport);
- 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 $ibx = {
- inboxdir => $inboxdir,
- name => 'test-v2writable',
- version => 2,
- -primary_address => 'test@example.com',
+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.<<EOM)) or BAIL_OUT;
+Content-Type: text/plain; charset=utf-8
+Content-Disposition: inline
+Content-Transfer-Encoding: 8bit
+
+cr_mismatch
+pipe \x{e2}\x{94}\x{82} or not
+EOM
+ $im->add(PublicInbox::Eml->new($common.<<EOM)) or BAIL_OUT;
+Content-Type: text/plain; charset="windows-1252"
+Content-Transfer-Encoding: quoted-printable
+
+cr_mismatch\r
+pipe =E2=94=82 or not
+EOM