1 # Copyright (C) 2018-2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use PublicInbox::Import;
7 use PublicInbox::TestCommon;
9 require_mods(qw(DBD::SQLite Xapian));
10 require PublicInbox::SearchIdx;
11 my ($inboxdir, $for_destroy) = tmpdir();
13 inboxdir => $inboxdir,
14 name => 'test-add-remove-add',
15 -primary_address => 'test@example.com',
17 $ibx = PublicInbox::Inbox->new($ibx);
18 my $mime = PublicInbox::Eml->new(<<'EOF');
21 Subject: this is a subject
23 Date: Fri, 02 Oct 1993 00:00:00 +0000
27 my $im = PublicInbox::Import->new($ibx->git, undef, undef, $ibx);
29 ok($im->add($mime), 'message added');
30 ok($im->remove($mime), 'message removed');
31 ok($im->add($mime), 'message added again');
33 my $rw = PublicInbox::SearchIdx->new($ibx, 1);
35 my $msgs = $ibx->over->recent({limit => 10});
36 is($msgs->[0]->{mid}, 'a-mid@b', 'message exists in history');
37 is(scalar @$msgs, 1, 'only one message in history');
38 is($ibx->mm->num_for('a-mid@b'), 2, 'exists with second article number');