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 require './t/common.perl';
10 foreach my $mod (qw(DBD::SQLite Search::Xapian)) {
12 plan skip_all => "$mod missing for v2-add-remove-add.t" if $@;
14 use_ok 'PublicInbox::V2Writable';
15 my ($inboxdir, $for_destroy) = tmpdir();
17 inboxdir => "$inboxdir/v2",
18 name => 'test-v2writable',
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::V2Writable->new($ibx, 1);
35 ok($im->add($mime), 'message added');
36 ok($im->remove($mime), 'message added');
37 ok($im->add($mime), 'message added again');
39 my $msgs = $ibx->recent({limit => 1000});
40 is($msgs->[0]->{mid}, 'a-mid@b', 'message exists in history');
41 is(scalar @$msgs, 1, 'only one message in history');