]> Sergey Matveev's repositories - public-inbox.git/blob - t/html_index.t
remove XML::Atom::SimpleFeed dependency
[public-inbox.git] / t / html_index.t
1 # Copyright (C) 2014, Eric Wong <normalperson@yhbt.net> and all contributors
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::Simple;
7 use PublicInbox::Feed;
8 use File::Temp qw/tempdir/;
9 my $tmpdir = tempdir(CLEANUP => 1);
10 my $git_dir = "$tmpdir/gittest";
11
12 # setup
13 {
14         is(0, system(qw(git init -q --bare), $git_dir), "git init");
15         my $prev = "";
16
17         foreach my $i (1..6) {
18                 local $ENV{GIT_DIR} = $git_dir;
19                 my $pid = open(my $pipe, "|-");
20                 defined $pid or die "fork/pipe failed: $!\n";
21                 if ($pid == 0) {
22                         exec("ssoma-mda", $git_dir);
23                 }
24                 my $mid = "<$i\@example.com>";
25                 my $mid_line = "Message-ID: $mid";
26                 if ($prev) {
27                         $mid_line .= "In-Reply-To: $prev";
28                 }
29                 $prev = $mid;
30                 my $simple = Email::Simple->new(<<EOF);
31 From: ME <me\@example.com>
32 To: U <u\@example.com>
33 $mid_line
34 Subject: zzz #$i
35 Date: Thu, 01 Jan 1970 00:00:00 +0000
36
37 > This is a long multi line quote so it should not be allowed to
38 > show up in its entirty in the Atom feed.  drop me
39
40 msg $i
41
42 > inline me here, short quote
43
44 keep me
45 EOF
46                 print $pipe $simple->as_string or die "print failed: $!\n";
47                 close $pipe or die "close pipe failed: $!\n";
48         }
49 }
50
51 # check HTML index
52 {
53         use IO::File;
54         my $cb = PublicInbox::Feed::generate_html_index({
55                 git_dir => $git_dir,
56                 max => 3
57         });
58         require 't/common.perl';
59         like(stream_to_string($cb), qr/html/, "feed is valid HTML :)");
60 }
61
62 done_testing();