]> Sergey Matveev's repositories - public-inbox.git/blob - t/html_index.t
inbox: move field population logic to initializer
[public-inbox.git] / t / html_index.t
1 # Copyright (C) 2014-2015 all contributors <meta@public-inbox.org>
2 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
3 use strict;
4 use warnings;
5 use Test::More;
6 use Email::MIME;
7 use PublicInbox::Feed;
8 use PublicInbox::Git;
9 use PublicInbox::Import;
10 use PublicInbox::Inbox;
11 use File::Temp qw/tempdir/;
12 my $tmpdir = tempdir('pi-http-XXXXXX', TMPDIR => 1, CLEANUP => 1);
13 my $git_dir = "$tmpdir/gittest";
14 my $ibx = PublicInbox::Inbox->new({
15         address => 'test@example',
16         name => 'tester',
17         mainrepo => $git_dir,
18         url => 'http://example.com/test',
19 });
20 my $git = $ibx->git;
21 my $im = PublicInbox::Import->new($git, 'tester', 'test@example');
22
23 # setup
24 {
25         is(0, system(qw(git init -q --bare), $git_dir), "git init");
26         my $prev = "";
27
28         foreach my $i (1..6) {
29                 # my $pid = open(my $pipe, "|-");
30                 # defined $pid or die "fork/pipe failed: $!\n";
31                 # if ($pid == 0) {
32                         # exec("ssoma-mda", $git_dir);
33                 # }
34                 my $mid = "<$i\@example.com>";
35                 my $mid_line = "Message-ID: $mid";
36                 if ($prev) {
37                         $mid_line .= "In-Reply-To: $prev";
38                 }
39                 $prev = $mid;
40                 my $mime = Email::MIME->new(<<EOF);
41 From: ME <me\@example.com>
42 To: U <u\@example.com>
43 $mid_line
44 Subject: zzz #$i
45 Date: Thu, 01 Jan 1970 00:00:00 +0000
46
47 > This is a long multi line quote so it should not be allowed to
48 > show up in its entirty in the Atom feed.  drop me
49
50 msg $i
51
52 > inline me here, short quote
53
54 keep me
55 EOF
56                 like($im->add($mime), qr/\A:\d+\z/, 'inserted message');
57         }
58         $im->done;
59 }
60
61 # check HTML index
62 {
63         use IO::File;
64         my $cb = PublicInbox::Feed::generate_html_index({
65                 -inbox => $ibx,
66                 max => 3
67         });
68         require 't/common.perl';
69         like(stream_to_string($cb), qr/html/, "feed is valid HTML :)");
70 }
71
72 done_testing();