X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fpsgi_scan_all.t;h=09e8eaf921dce304eb21ab0550559ccb68bd210c;hb=80690e594710f2fb89d306f1f5faf4a57aea79c8;hp=fa636d324cbfd8888f99e7649d8495adfad6d0a5;hpb=3c313f9034aac96182e2efdc2f92c40803626f32;p=public-inbox.git
diff --git a/t/psgi_scan_all.t b/t/psgi_scan_all.t
index fa636d32..09e8eaf9 100644
--- a/t/psgi_scan_all.t
+++ b/t/psgi_scan_all.t
@@ -1,55 +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 PublicInbox::Config;
+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, $for_destroy) = tmpdir();
my $cfg = '';
-
foreach my $i (1..2) {
- my $cfgpfx = "publicinbox.test-$i";
- my $addr = "test-$i\@example.com";
- my $inboxdir = "$tmp/$i";
- $cfg .= "$cfgpfx.address=$addr\n";
- $cfg .= "$cfgpfx.inboxdir=$inboxdir\n";
- $cfg .= "$cfgpfx.url=http://example.com/$i\n";
- my $opt = {
- inboxdir => $inboxdir,
- 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) = @_;
@@ -67,5 +50,4 @@ test_psgi(sub { $www->call(@_) }, sub {
is($res->code, 404, "404 on $x");
}
});
-
-done_testing();
+done_testing;