]> Sergey Matveev's repositories - public-inbox.git/blob - t/v2-add-remove-add.t
www: drop --subject from "git send-email" instructions
[public-inbox.git] / t / v2-add-remove-add.t
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>
3 use strict;
4 use warnings;
5 use Test::More;
6 use PublicInbox::Eml;
7 use PublicInbox::TestCommon;
8 require_git(2.6);
9 require_mods(qw(DBD::SQLite Search::Xapian));
10 use_ok 'PublicInbox::V2Writable';
11 my ($inboxdir, $for_destroy) = tmpdir();
12 my $ibx = {
13         inboxdir => "$inboxdir/v2",
14         name => 'test-v2writable',
15         version => 2,
16         -no_fsync => 1,
17         -primary_address => 'test@example.com',
18 };
19 $ibx = PublicInbox::Inbox->new($ibx);
20 my $mime = PublicInbox::Eml->new(<<'EOF');
21 From: a@example.com
22 To: test@example.com
23 Subject: this is a subject
24 Date: Fri, 02 Oct 1993 00:00:00 +0000
25 Message-ID: <a-mid@b>
26
27 hello world
28 EOF
29 my $im = PublicInbox::V2Writable->new($ibx, 1);
30 $im->{parallel} = 0;
31 ok($im->add($mime), 'message added');
32 ok($im->remove($mime), 'message removed');
33 ok($im->add($mime), 'message added again');
34 $im->done;
35 my $msgs = $ibx->recent({limit => 1000});
36 is($msgs->[0]->{mid}, 'a-mid@b', 'message exists in history');
37 is(scalar @$msgs, 1, 'only one message in history');
38
39 done_testing();