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>
7 use PublicInbox::TestCommon;
9 use PublicInbox::InboxWritable;
10 use PublicInbox::Config;
11 use List::Util qw(shuffle);
12 require_mods(qw(DBD::SQLite));
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>
20 Subject: [bug#45000] [PATCH 0/9]
21 Message-Id: <20201202045335.31096-1-j@example.com>
23 Subject: [bug#45000] [PATCH 0/9]
24 References: <20201202045335.31096-1-j@example.com>
25 Message-ID: <86sg8o1mou.fsf@example.com>
27 Subject: [bug#45000] [PATCH 8/9]
28 Message-Id: <20201202045540.31248-8-j@example.com>
29 References: <20201202045540.31248-1-j@example.com>
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
41 my $ibx = PublicInbox::Config->new->lookup_name($n);
42 my $im = PublicInbox::InboxWritable->new($ibx)->importer(0);
44 $im->add(PublicInbox::Eml->new("$m\nFrom: x\@example.com\n\n"));
47 my $over = $ibx->over;
49 my $tid = $dbh->selectall_arrayref('SELECT DISTINCT(tid) FROM over');
50 my @tid = map { $_->[0] } @$tid;
51 is(scalar(@tid), 1, "only one thread initially ($desc)");
53 run_script([qw(-index --reindex --rethread), $ibx->{inboxdir}]) or
55 $tid = $dbh->selectall_arrayref('SELECT DISTINCT(tid) FROM over');
56 @tid = map { $_->[0] } @$tid;
57 is(scalar(@tid), 1, "only one thread after rethread ($desc)");