X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fhtml_index.t;h=b9f866b3e842061744c2dac168df8cd1ea72da18;hb=b41c19abcf0b0ac8a5f55678bfb0058ad50b3179;hp=80a8899778b57198eb1b46fcbe3651c258aea59b;hpb=7a42c9451400e20dcc6fbef21f88a68da16aa708;p=public-inbox.git diff --git a/t/html_index.t b/t/html_index.t index 80a88997..b9f866b3 100644 --- a/t/html_index.t +++ b/t/html_index.t @@ -1,13 +1,24 @@ -# Copyright (C) 2014, Eric Wong and all contributors -# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt) +# Copyright (C) 2014-2019 all contributors +# License: AGPL-3.0+ use strict; use warnings; use Test::More; -use Email::Simple; +use Email::MIME; use PublicInbox::Feed; +use PublicInbox::Git; +use PublicInbox::Import; +use PublicInbox::Inbox; use File::Temp qw/tempdir/; -my $tmpdir = tempdir(CLEANUP => 1); +my $tmpdir = tempdir('pi-http-XXXXXX', TMPDIR => 1, CLEANUP => 1); my $git_dir = "$tmpdir/gittest"; +my $ibx = PublicInbox::Inbox->new({ + address => 'test@example', + name => 'tester', + mainrepo => $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\n"; + my $mid_line = "Message-ID: $mid"; if ($prev) { - $mid_line .= "In-Reply-To: $prev\n"; + $mid_line .= "In-Reply-To: $prev"; } $prev = $mid; - my $simple = Email::Simple->new(<new(< To: U $mid_line @@ -43,18 +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 -{ - my $feed = PublicInbox::Feed->generate_html_index({ - git_dir => $git_dir, - max => 3 - }); - like($feed, qr/html/, "feed is valid HTML :)"); + $im->done; } done_testing();