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 use PublicInbox::TestCommon;
8 require_mods(qw(DBD::SQLite Search::Xapian));
9 use_ok 'PublicInbox::V2Writable';
10 use_ok 'PublicInbox::Inbox';
11 my ($tmpdir, $for_destroy) = tmpdir();
12 my $inboxdir = "$tmpdir/inbox";
13 my $full = "$tmpdir/inbox/another-nntp.sqlite3";
14 my $altid = [ 'serial:gmane:file=another-nntp.sqlite3' ];
17 ok(mkdir($inboxdir), 'created repo for msgmap');
18 my $mm = PublicInbox::Msgmap->new_file($full, 1);
19 is($mm->mid_set(1234, 'a@example.com'), 1, 'mid_set once OK');
20 ok(0 == $mm->mid_set(1234, 'a@example.com'), 'mid_set not idempotent');
21 ok(0 == $mm->mid_set(1, 'a@example.com'), 'mid_set fails with dup MID');
25 inboxdir => $inboxdir,
26 name => 'test-v2writable',
28 -primary_address => 'test@example.com',
31 $ibx = PublicInbox::Inbox->new($ibx);
32 my $v2w = PublicInbox::V2Writable->new($ibx, 1);
33 $v2w->add(Email::MIME->create(
35 From => 'a@example.com',
36 To => 'b@example.com',
37 'Content-Type' => 'text/plain',
39 'Message-ID' => '<a@example.com>',
41 body => "hello world gmane:666\n",
45 my $msgs = $ibx->search->reopen->query("gmane:1234");
46 is_deeply([map { $_->mid } @$msgs], ['a@example.com'], 'got one match');
47 $msgs = $ibx->search->query("gmane:666");
48 is_deeply([], $msgs, 'body did NOT match');