From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 9C2071FAE4 for ; Mon, 2 Apr 2018 00:04:57 +0000 (UTC) From: "Eric Wong (Contractor, The Linux Foundation)" To: meta@public-inbox.org Subject: [PATCH 3/5] t/over: test empty Subject: line matching Date: Mon, 2 Apr 2018 00:04:54 +0000 Message-Id: <20180402000456.13446-4-e@80x24.org> In-Reply-To: <20180402000456.13446-1-e@80x24.org> References: <20180402000456.13446-1-e@80x24.org> List-Id: We need to ensure we don't match NULL 'sid' columns in the `over' table. --- t/over.t | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/t/over.t b/t/over.t index 1d3f9b3..bfe331e 100644 --- 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(); -- EW