X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fpsgi_scan_all.t;h=09e8eaf921dce304eb21ab0550559ccb68bd210c;hb=94a70f57bf1b449192c9d68637cf985b8d5cfaca;hp=5d4cc263a093dabd9b86d7780f96210562c8bb83;hpb=ad6f26f3b9f0e428020d05667987556f8fcbec2f;p=public-inbox.git
diff --git a/t/psgi_scan_all.t b/t/psgi_scan_all.t
index 5d4cc263..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 v5.10.1;
+use PublicInbox::TestCommon;
+use PublicInbox::Eml;
use PublicInbox::Config;
-require './t/common.perl';
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;