]> Sergey Matveev's repositories - public-inbox.git/blob - t/thread-index-gap.t
update copyrights for 2021
[public-inbox.git] / t / thread-index-gap.t
1 #!perl -w
2 # Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 use strict;
5 use v5.10.1;
6 use Test::More;
7 use PublicInbox::TestCommon;
8 use PublicInbox::Eml;
9 use PublicInbox::InboxWritable;
10 use PublicInbox::Config;
11 use List::Util qw(shuffle);
12 require_mods(qw(DBD::SQLite));
13 require_git(2.6);
14
15 chomp(my @msgs = split(/\n\n/, <<'EOF')); # "git log" order
16 Subject: [bug#45000] [PATCH 1/9]
17 References: <20201202045335.31096-1-j@example.com>
18 Message-Id: <20201202045540.31248-1-j@example.com>
19
20 Subject: [bug#45000] [PATCH 0/9]
21 Message-Id: <20201202045335.31096-1-j@example.com>
22
23 Subject: [bug#45000] [PATCH 0/9]
24 References: <20201202045335.31096-1-j@example.com>
25 Message-ID: <86sg8o1mou.fsf@example.com>
26
27 Subject: [bug#45000] [PATCH 8/9]
28 Message-Id: <20201202045540.31248-8-j@example.com>
29 References: <20201202045540.31248-1-j@example.com>
30
31 EOF
32
33 my ($home, $for_destroy) = tmpdir();
34 local $ENV{HOME} = $home;
35 for my $msgs (['orig', reverse @msgs], ['shuffle', shuffle(@msgs)]) {
36         my $desc = shift @$msgs;
37         my $n = "index-cap-$desc";
38         run_script([qw(-init -L basic -V2), $n, "$home/$n",
39                 "http://example.com/$n", "$n\@example.com"]) or
40                 BAIL_OUT 'init';
41         my $ibx = PublicInbox::Config->new->lookup_name($n);
42         my $im = PublicInbox::InboxWritable->new($ibx)->importer(0);
43         for my $m (@$msgs) {
44                 $im->add(PublicInbox::Eml->new("$m\nFrom: x\@example.com\n\n"));
45         }
46         $im->done;
47         my $over = $ibx->over;
48         my @tid = $over->dbh->selectall_array('SELECT DISTINCT(tid) FROM over');
49         is(scalar(@tid), 1, "only one thread initially ($desc)");
50         $over->dbh_close;
51         run_script([qw(-index --reindex --rethread), $ibx->{inboxdir}]) or
52                 BAIL_OUT 'rethread';
53         @tid = $over->dbh->selectall_array('SELECT DISTINCT(tid) FROM over');
54         is(scalar(@tid), 1, "only one thread after rethread ($desc)");
55 }
56
57 done_testing;