]> Sergey Matveev's repositories - public-inbox.git/blob - t/html_index.t
feed: various object-orientation cleanups
[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         -primary_address => 'test@example',
17         name => 'tester',
18         mainrepo => $git_dir,
19         url => 'http://example.com/test',
20 });
21 my $git = $ibx->git;
22 my $im = PublicInbox::Import->new($git, 'tester', 'test@example');
23
24 # setup
25 {
26         is(0, system(qw(git init -q --bare), $git_dir), "git init");
27         my $prev = "";
28
29         foreach my $i (1..6) {
30                 # my $pid = open(my $pipe, "|-");
31                 # defined $pid or die "fork/pipe failed: $!\n";
32                 # if ($pid == 0) {
33                         # exec("ssoma-mda", $git_dir);
34                 # }
35                 my $mid = "<$i\@example.com>";
36                 my $mid_line = "Message-ID: $mid";
37                 if ($prev) {
38                         $mid_line .= "In-Reply-To: $prev";
39                 }
40                 $prev = $mid;
41                 my $mime = Email::MIME->new(<<EOF);
42 From: ME <me\@example.com>
43 To: U <u\@example.com>
44 $mid_line
45 Subject: zzz #$i
46 Date: Thu, 01 Jan 1970 00:00:00 +0000
47
48 > This is a long multi line quote so it should not be allowed to
49 > show up in its entirty in the Atom feed.  drop me
50
51 msg $i
52
53 > inline me here, short quote
54
55 keep me
56 EOF
57                 like($im->add($mime), qr/\A:\d+\z/, 'inserted message');
58         }
59         $im->done;
60 }
61
62 # check HTML index
63 {
64         use IO::File;
65         my $cb = PublicInbox::Feed::generate_html_index({
66                 -inbox => $ibx,
67                 max => 3
68         });
69         require 't/common.perl';
70         like(stream_to_string($cb), qr/html/, "feed is valid HTML :)");
71 }
72
73 done_testing();