1 # Copyright (C) 2018-2019 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
7 use PublicInbox::Import;
8 use PublicInbox::TestCommon;
10 foreach my $mod (qw(DBD::SQLite Search::Xapian)) {
12 plan skip_all => "$mod missing for v1-add-remove-add.t" if $@;
14 require PublicInbox::SearchIdx;
15 my ($inboxdir, $for_destroy) = tmpdir();
16 is(system(qw(git init --bare -q), $inboxdir), 0);
18 inboxdir => $inboxdir,
19 name => 'test-add-remove-add',
20 -primary_address => 'test@example.com',
22 $ibx = PublicInbox::Inbox->new($ibx);
23 my $mime = PublicInbox::MIME->create(
25 From => 'a@example.com',
26 To => 'test@example.com',
27 Subject => 'this is a subject',
28 Date => 'Fri, 02 Oct 1993 00:00:00 +0000',
29 'Message-ID' => '<a-mid@b>',
31 body => "hello world\n",
33 my $im = PublicInbox::Import->new($ibx->git, undef, undef, $ibx);
34 ok($im->add($mime), 'message added');
35 ok($im->remove($mime), 'message added');
36 ok($im->add($mime), 'message added again');
38 my $rw = PublicInbox::SearchIdx->new($ibx, 1);
40 my $msgs = $ibx->recent({limit => 10});
41 is($msgs->[0]->{mid}, 'a-mid@b', 'message exists in history');
42 is(scalar @$msgs, 1, 'only one message in history');
43 is($ibx->mm->num_for('a-mid@b'), 2, 'exists with second article number');