1 # Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 require './t/common.perl';
8 foreach my $mod (qw(DBD::SQLite Search::Xapian)) {
10 plan skip_all => "$mod missing for altid_v2.t" if $@;
13 use_ok 'PublicInbox::V2Writable';
14 use_ok 'PublicInbox::Inbox';
15 my ($tmpdir, $for_destroy) = tmpdir();
16 my $inboxdir = "$tmpdir/inbox";
17 my $full = "$tmpdir/inbox/another-nntp.sqlite3";
18 my $altid = [ 'serial:gmane:file=another-nntp.sqlite3' ];
21 ok(mkdir($inboxdir), 'created repo for msgmap');
22 my $mm = PublicInbox::Msgmap->new_file($full, 1);
23 is($mm->mid_set(1234, 'a@example.com'), 1, 'mid_set once OK');
24 ok(0 == $mm->mid_set(1234, 'a@example.com'), 'mid_set not idempotent');
25 ok(0 == $mm->mid_set(1, 'a@example.com'), 'mid_set fails with dup MID');
29 inboxdir => $inboxdir,
30 name => 'test-v2writable',
32 -primary_address => 'test@example.com',
35 $ibx = PublicInbox::Inbox->new($ibx);
36 my $v2w = PublicInbox::V2Writable->new($ibx, 1);
37 $v2w->add(Email::MIME->create(
39 From => 'a@example.com',
40 To => 'b@example.com',
41 'Content-Type' => 'text/plain',
43 'Message-ID' => '<a@example.com>',
45 body => "hello world gmane:666\n",
49 my $msgs = $ibx->search->reopen->query("gmane:1234");
50 is_deeply([map { $_->mid } @$msgs], ['a@example.com'], 'got one match');
51 $msgs = $ibx->search->query("gmane:666");
52 is_deeply([], $msgs, 'body did NOT match');