]> Sergey Matveev's repositories - public-inbox.git/commitdiff
t/over: test empty Subject: line matching
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Mon, 2 Apr 2018 00:04:54 +0000 (00:04 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Mon, 2 Apr 2018 00:05:41 +0000 (00:05 +0000)
We need to ensure we don't match NULL 'sid' columns in the
`over' table.

t/over.t

index 1d3f9b37ac2b5acc6c91c5207f40725a2717f6e9..bfe331ede2cbc5c75db85c942aa4f087bf1ad9d6 100644 (file)
--- a/t/over.t
+++ b/t/over.t
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use File::Temp qw/tempdir/;
+use Compress::Zlib qw(compress);
 foreach my $mod (qw(DBD::SQLite)) {
        eval "require $mod";
        plan skip_all => "$mod missing for over.t" if $@;
@@ -35,4 +36,28 @@ is(int($x), $x, 'integer tid for ghost');
 $y = $over->create_ghost('NEVAR');
 is($y, $x + 1, 'integer tid for ghost increases');
 
+my $ddd = compress('');
+foreach my $s ('', undef) {
+       $over->add_over([0, 98, [ 'a' ], [], $s, $ddd]);
+       $over->add_over([0, 99, [ 'b' ], [], $s, $ddd]);
+       my $msgs = [ map { $_->{num} } @{$over->get_thread('a')->{msgs}} ];
+       is_deeply([98], $msgs,
+               'messages not linked by empty subject');
+}
+
+$over->add_over([0, 98, [ 'a' ], [], 's', $ddd]);
+$over->add_over([0, 99, [ 'b' ], [], 's', $ddd]);
+foreach my $mid (qw(a b)) {
+       my $msgs = [ map { $_->{num} } @{$over->get_thread('a')->{msgs}} ];
+       is_deeply([98, 99], $msgs, 'linked messages by subject');
+}
+$over->add_over([0, 98, [ 'a' ], [], 's', $ddd]);
+$over->add_over([0, 99, [ 'b' ], ['a'], 'diff', $ddd]);
+foreach my $mid (qw(a b)) {
+       my $msgs = [ map { $_->{num} } @{$over->get_thread($mid)->{msgs}} ];
+       is_deeply([98, 99], $msgs, "linked messages by Message-ID: <$mid>");
+}
+
+$over->rollback_lazy;
+
 done_testing();