about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-03-15 12:58:10 +0100
committerEric Wong <e@80x24.org>2021-03-15 16:54:30 -0400
commite74ac338b47081a0425fed799323947ac185c202 (patch)
tree70230cc2ebc57cbdf0651692789a7d46a1a37703 /t
parentb19c3afd16fdee23409bd7475c994f02fb30d273 (diff)
downloadpublic-inbox-e74ac338b47081a0425fed799323947ac185c202.tar.gz
A fair mount of setup code goes away and saves us a few
hundred milliseconds.
Diffstat (limited to 't')
-rw-r--r--t/psgi_scan_all.t48
1 files changed, 16 insertions, 32 deletions
diff --git a/t/psgi_scan_all.t b/t/psgi_scan_all.t
index 80b855e1..09e8eaf9 100644
--- a/t/psgi_scan_all.t
+++ b/t/psgi_scan_all.t
@@ -1,53 +1,38 @@
+#!perl -w
 # Copyright (C) 2019-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
-use warnings;
-use Test::More;
+use v5.10.1;
+use PublicInbox::TestCommon;
 use PublicInbox::Eml;
 use PublicInbox::Config;
-use PublicInbox::TestCommon;
 my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape DBD::SQLite);
 require_git 2.6;
 require_mods(@mods);
-use_ok 'PublicInbox::V2Writable';
+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::Eml->new(<<EOF);
+        my $ibx = create_inbox "test-$i", version => 2, indexlevel => 'basic',
+        sub {
+                my ($im, $ibx) = @_;
+                $im->add(PublicInbox::Eml->new(<<EOF)) or BAIL_OUT;
 From: a\@example.com
-To: $addr
+To: $ibx->{-primary_address}
 Subject: s$i
 Message-ID: <a-mid-$i\@b>
 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;