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