From 73214b02e581ef0a037d85a1ae37ff425654d7b3 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 25 Aug 2015 02:03:16 +0000 Subject: search: implement subject summarization We ought to summarize subjects to avoid exploding line lengths in the web interface. --- t/search.t | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 't') diff --git a/t/search.t b/t/search.t index 17e9eaf4..65539f14 100644 --- a/t/search.t +++ b/t/search.t @@ -16,6 +16,23 @@ is(0, system(qw(git init -q --bare), $git_dir), "git init (main)"); eval { PublicInbox::Search->new($git_dir) }; ok($@, "exception raised on non-existent DB"); +{ + my $orig = "FOO " x 30; + my $summ = PublicInbox::Search::subject_summary($orig); + + $summ = length($summ); + $orig = length($orig); + ok($summ < $orig && $summ > 0, "summary shortened ($orig => $summ)"); + + $orig = "FOO" x 30; + $summ = PublicInbox::Search::subject_summary($orig); + + $summ = length($summ); + $orig = length($orig); + ok($summ < $orig && $summ > 0, + "summary shortened but not empty: $summ"); +} + my $rw = PublicInbox::SearchIdx->new($git_dir, 1); my $ro = PublicInbox::Search->new($git_dir); my $rw_commit = sub { -- cgit v1.2.3-24-ge0c7