1 # Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
7 use PublicInbox::TestCommon;
9 require_mods(qw(DBD::SQLite Search::Xapian));
10 use_ok 'PublicInbox::V2Writable';
11 use_ok 'PublicInbox::Inbox';
12 my ($tmpdir, $for_destroy) = tmpdir();
13 my $inboxdir = "$tmpdir/inbox";
14 my $full = "$tmpdir/inbox/another-nntp.sqlite3";
15 my $altid = [ 'serial:gmane:file=another-nntp.sqlite3' ];
18 ok(mkdir($inboxdir), 'created repo for msgmap');
19 my $mm = PublicInbox::Msgmap->new_file($full, 1);
20 is($mm->mid_set(1234, 'a@example.com'), 1, 'mid_set once OK');
21 ok(0 == $mm->mid_set(1234, 'a@example.com'), 'mid_set not idempotent');
22 ok(0 == $mm->mid_set(1, 'a@example.com'), 'mid_set fails with dup MID');
26 inboxdir => $inboxdir,
27 name => 'test-v2writable',
29 -primary_address => 'test@example.com',
32 $ibx = PublicInbox::Inbox->new($ibx);
33 my $v2w = PublicInbox::V2Writable->new($ibx, 1);
34 $v2w->add(PublicInbox::Eml->new(<<'EOF'));
38 Message-ID: <a@example.com>
44 my $mset = $ibx->search->reopen->mset('gmane:1234');
45 my $msgs = $ibx->search->mset_to_smsg($ibx, $mset);
46 $msgs = [ map { $_->{mid} } @$msgs ];
47 is_deeply($msgs, ['a@example.com'], 'got one match');
48 $mset = $ibx->search->mset('gmane:666');
49 is($mset->size, 0, 'body did NOT match');