2 # Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use PublicInbox::TestCommon;
9 require_mods(qw(DBD::SQLite Search::Xapian));
10 require PublicInbox::Msgmap;
11 my $another = 'another-nntp.sqlite3';
12 my $altid = [ "serial:gmane:file=$another" ];
13 my $ibx = create_inbox 'v2', version => 2, indexlevel => 'medium',
14 altid => $altid, sub {
16 my $mm = PublicInbox::Msgmap->new_file("$ibx->{inboxdir}/$another", 2);
17 is($mm->mid_set(1234, 'a@example.com'), 1, 'mid_set') or xbail 'once';
18 is($mm->mid_set(1234, 'a@example.com')+0, 0, 'mid_set not idempotent');
19 is($mm->mid_set(1, 'a@example.com')+0, 0, 'mid_set fails with dup MID');
20 $im->add(PublicInbox::Eml->new(<<'EOF')) or BAIL_OUT;
24 Message-ID: <a@example.com>
29 my $mm = PublicInbox::Msgmap->new_file("$ibx->{inboxdir}/$another", 2);
30 is($mm->mid_set(1234, 'a@example.com') + 0, 0, 'mid_set not idempotent');
31 is($mm->mid_set(1, 'a@example.com') + 0, 0, 'mid_set fails with dup MID');
32 my $mset = $ibx->search->mset('gmane:1234');
33 my $msgs = $ibx->search->mset_to_smsg($ibx, $mset);
34 $msgs = [ map { $_->{mid} } @$msgs ];
35 is_deeply($msgs, ['a@example.com'], 'got one match');
36 $mset = $ibx->search->mset('gmane:666');
37 is($mset->size, 0, 'body did NOT match');