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 $mm->mid_set(1234, 'a@example.com') == 1 or BAIL_OUT 'mid_set once';
18 ok(0 == $mm->mid_set(1234, 'a@example.com'), 'mid_set not idempotent');
19 ok(0 == $mm->mid_set(1, 'a@example.com'), '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 ok(0 == $mm->mid_set(1234, 'a@example.com'), 'mid_set not idempotent');
31 ok(0 == $mm->mid_set(1, 'a@example.com'), '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');