X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fhtml_index.t;h=8e2a674fe8fcd19d8626e99eb5e271f68d280294;hb=af0b0fb7a454470a32c452119d0392e0dedb3fe1;hp=6286fc479e874e135a303bdd9d684140e52faaf2;hpb=1704bdb4aabdbc155eb962edf51498f59b65c839;p=public-inbox.git diff --git a/t/html_index.t b/t/html_index.t index 6286fc47..8e2a674f 100644 --- a/t/html_index.t +++ b/t/html_index.t @@ -1,33 +1,38 @@ -# Copyright (C) 2014, Eric Wong and all contributors -# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt) +# Copyright (C) 2014-2021 all contributors +# License: AGPL-3.0+ use strict; use warnings; use Test::More; -use Email::Simple; +use PublicInbox::Eml; 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 { - is(0, system(qw(git init -q --bare), $git_dir), "git init"); + $im->init_bare; 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(<new(< To: U $mid_line @@ -43,30 +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 - }); - my $headers; - my $io = IO::File->new_tmpfile; - use POSIX qw/dup/; - my $dup = dup($io->fileno); - my $response = sub { $headers = \@_, $io }; - $cb->($response); - $io = IO::File->new; - $io->fdopen($dup, 'r+'); - $io->seek(0, 0); - $io->read(my $feed, 666666); - like($feed, qr/html/, "feed is valid HTML :)"); - $io->close; + $im->done; } done_testing();