]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/html_index.t
treewide: run update-copyrights from gnulib for 2019
[public-inbox.git] / t / html_index.t
index 50f5ae5eeffc9628e7e31bba283f11de67ea599d..158a7862cfdd07abc9828ff2fe6e60d7bc5c0657 100644 (file)
@@ -1,13 +1,24 @@
-# Copyright (C) 2014-2015 all contributors <meta@public-inbox.org>
-# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
+# Copyright (C) 2014-2020 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use warnings;
 use Test::More;
-use Email::Simple;
+use Email::MIME;
 use PublicInbox::Feed;
-use File::Temp qw/tempdir/;
-my $tmpdir = tempdir(CLEANUP => 1);
+use PublicInbox::Git;
+use PublicInbox::Import;
+use PublicInbox::Inbox;
+use PublicInbox::TestCommon;
+my ($tmpdir, $for_destroy) = tmpdir();
 my $git_dir = "$tmpdir/gittest";
+my $ibx = PublicInbox::Inbox->new({
+       address => 'test@example',
+       name => 'tester',
+       inboxdir => $git_dir,
+       url => 'http://example.com/test',
+});
+my $git = $ibx->git;
+my $im = PublicInbox::Import->new($git, 'tester', 'test@example');
 
 # setup
 {
@@ -15,19 +26,13 @@ my $git_dir = "$tmpdir/gittest";
        my $prev = "";
 
        foreach my $i (1..6) {
-               local $ENV{GIT_DIR} = $git_dir;
-               my $pid = open(my $pipe, "|-");
-               defined $pid or die "fork/pipe failed: $!\n";
-               if ($pid == 0) {
-                       exec("ssoma-mda", $git_dir);
-               }
                my $mid = "<$i\@example.com>";
                my $mid_line = "Message-ID: $mid";
                if ($prev) {
                        $mid_line .= "In-Reply-To: $prev";
                }
                $prev = $mid;
-               my $simple = Email::Simple->new(<<EOF);
+               my $mime = Email::MIME->new(<<EOF);
 From: ME <me\@example.com>
 To: U <u\@example.com>
 $mid_line
@@ -43,20 +48,9 @@ msg $i
 
 keep me
 EOF
-               print $pipe $simple->as_string or die "print failed: $!\n";
-               close $pipe or die "close pipe failed: $!\n";
+               like($im->add($mime), qr/\A:\d+\z/, 'inserted message');
        }
-}
-
-# check HTML index
-{
-       use IO::File;
-       my $cb = PublicInbox::Feed::generate_html_index({
-               git_dir => $git_dir,
-               max => 3
-       });
-       require 't/common.perl';
-       like(stream_to_string($cb), qr/html/, "feed is valid HTML :)");
+       $im->done;
 }
 
 done_testing();