X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fpsgi_scan_all.t;h=09e8eaf921dce304eb21ab0550559ccb68bd210c;hb=4eee5af6011cc8cdefb66c9729952c7eff5c0b0b;hp=2f54c8207578303bcc92f06facf880d19a388c4d;hpb=e220b8b2ee5cfd458167dc2c6c92726352c4c80e;p=public-inbox.git diff --git a/t/psgi_scan_all.t b/t/psgi_scan_all.t index 2f54c820..09e8eaf9 100644 --- a/t/psgi_scan_all.t +++ b/t/psgi_scan_all.t @@ -1,53 +1,38 @@ -# Copyright (C) 2019 all contributors +#!perl -w +# Copyright (C) 2019-2021 all contributors # License: AGPL-3.0+ use strict; -use warnings; -use Test::More; -use Email::MIME; -use File::Temp qw/tempdir/; +use v5.10.1; +use PublicInbox::TestCommon; +use PublicInbox::Eml; use PublicInbox::Config; my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape DBD::SQLite); -foreach my $mod (@mods) { - eval "require $mod"; - plan skip_all => "$mod missing for psgi_scan_all.t" if $@; -} -use_ok 'PublicInbox::V2Writable'; +require_git 2.6; +require_mods(@mods); +use_ok 'PublicInbox::WWW'; foreach my $mod (@mods) { use_ok $mod; } -my $tmp = tempdir('pi-scan_all-XXXXXX', TMPDIR => 1, CLEANUP => 1); -my $cfg = {}; - +my $cfg = ''; foreach my $i (1..2) { - my $cfgpfx = "publicinbox.test-$i"; - my $addr = $cfg->{"$cfgpfx.address"} = "test-$i\@example.com"; - my $mainrepo = $cfg->{"$cfgpfx.mainrepo"} = "$tmp/$i"; - $cfg->{"$cfgpfx.url"} = "http://example.com/$i"; - my $opt = { - mainrepo => $mainrepo, - name => "test-$i", - version => 2, - indexlevel => 'basic', - -primary_address => $addr, - }; - my $ibx = PublicInbox::Inbox->new($opt); - my $im = PublicInbox::V2Writable->new($ibx, 1); - $im->{parallel} = 0; - $im->init_inbox(0); - my $mime = PublicInbox::MIME->new(< 2, indexlevel => 'basic', + sub { + my ($im, $ibx) = @_; + $im->add(PublicInbox::Eml->new(<{-primary_address} Subject: s$i Message-ID: Date: Fri, 02 Oct 1993 00:00:00 +0000 hello world EOF + }; + my $cfgpfx = "publicinbox.test-$i"; + $cfg .= "$cfgpfx.address=$ibx->{-primary_address}\n"; + $cfg .= "$cfgpfx.inboxdir=$ibx->{inboxdir}\n"; + $cfg .= "$cfgpfx.url=http://example.com/$i\n"; - ok($im->add($mime), "added message to $i"); - $im->done; } -my $config = PublicInbox::Config->new($cfg); -use_ok 'PublicInbox::WWW'; -my $www = PublicInbox::WWW->new($config); +my $www = PublicInbox::WWW->new(PublicInbox::Config->new(\$cfg)); test_psgi(sub { $www->call(@_) }, sub { my ($cb) = @_; @@ -65,5 +50,4 @@ test_psgi(sub { $www->call(@_) }, sub { is($res->code, 404, "404 on $x"); } }); - -done_testing(); +done_testing;