X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fover.t;h=48c835f80c8ca6abb4fad3baadcbe2731d0f7f85;hb=4821798351defce82c102e46d6f5f84f0cdc0e34;hp=1d3f9b37ac2b5acc6c91c5207f40725a2717f6e9;hpb=35ff6bb106909b1c1232666a9792156dfa398ea8;p=public-inbox.git diff --git a/t/over.t b/t/over.t index 1d3f9b37..48c835f8 100644 --- a/t/over.t +++ b/t/over.t @@ -1,9 +1,10 @@ -# Copyright (C) 2018 all contributors +# Copyright (C) 2018-2019 all contributors # License: AGPL-3.0+ 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, 0, 98, [ 'a' ], [], $s, $ddd]); + $over->add_over([0, 0, 99, [ 'b' ], [], $s, $ddd]); + my $msgs = [ map { $_->{num} } @{$over->get_thread('a')} ]; + is_deeply([98], $msgs, + 'messages not linked by empty subject'); +} + +$over->add_over([0, 0, 98, [ 'a' ], [], 's', $ddd]); +$over->add_over([0, 0, 99, [ 'b' ], [], 's', $ddd]); +foreach my $mid (qw(a b)) { + my $msgs = [ map { $_->{num} } @{$over->get_thread('a')} ]; + is_deeply([98, 99], $msgs, 'linked messages by subject'); +} +$over->add_over([0, 0, 98, [ 'a' ], [], 's', $ddd]); +$over->add_over([0, 0, 99, [ 'b' ], ['a'], 'diff', $ddd]); +foreach my $mid (qw(a b)) { + my $msgs = [ map { $_->{num} } @{$over->get_thread($mid)} ]; + is_deeply([98, 99], $msgs, "linked messages by Message-ID: <$mid>"); +} + +$over->rollback_lazy; + done_testing();