From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id CEA5E1FA01 for ; Mon, 15 Mar 2021 11:58:27 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 04/35] t/imapd-tls: switch to create_inbox Date: Mon, 15 Mar 2021 12:57:55 +0100 Message-Id: <20210315115826.17591-5-e@80x24.org> In-Reply-To: <20210315115826.17591-1-e@80x24.org> References: <20210315115826.17591-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This saves another few dozen milliseconds and LoC. --- t/imapd-tls.t | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/t/imapd-tls.t b/t/imapd-tls.t index ab90ddec..125846e2 100644 --- a/t/imapd-tls.t +++ b/t/imapd-tls.t @@ -25,50 +25,32 @@ unless (-r $key && -r $cert) { } use_ok 'PublicInbox::TLS'; use_ok 'IO::Socket::SSL'; -use PublicInbox::InboxWritable; -require PublicInbox::SearchIdx; my $version = 1; # v2 needs newer git require_git('2.6') if $version >= 2; my ($tmpdir, $for_destroy) = tmpdir(); my $err = "$tmpdir/stderr.log"; my $out = "$tmpdir/stdout.log"; -my $inboxdir = "$tmpdir"; -my $pi_config = "$tmpdir/pi_config"; +my $pi_config; my $group = 'test-imapd-tls'; my $addr = $group . '@example.com'; my $starttls = tcp_server(); my $imaps = tcp_server(); -my $ibx = PublicInbox::Inbox->new({ - inboxdir => $inboxdir, - name => 'imapd-tls', - version => $version, - -primary_address => $addr, - indexlevel => 'basic', -}); -$ibx = PublicInbox::InboxWritable->new($ibx, {nproc=>1}); -$ibx->init_inbox(0); -{ +my $ibx = create_inbox 'imapd-tls', version => $version, + -primary_address => $addr, indexlevel => 'basic', sub { + my ($im, $ibx) = @_; + $im->add(eml_load('t/data/0001.patch')) or BAIL_OUT '->add'; + $pi_config = "$ibx->{inboxdir}/pi_config"; open my $fh, '>', $pi_config or BAIL_OUT "open: $!"; - print $fh <{inboxdir} address = $addr indexlevel = basic newsgroup = $group EOF - ; close $fh or BAIL_OUT "close: $!\n"; -} - -{ - my $im = $ibx->importer(0); - ok($im->add(eml_load('t/data/0001.patch')), 'message added'); - $im->done; - if ($version == 1) { - my $s = PublicInbox::SearchIdx->new($ibx, 1); - $s->index_sync; - } -} +}; +$pi_config //= "$ibx->{inboxdir}/pi_config"; my $imaps_addr = tcp_host_port($imaps); my $starttls_addr = tcp_host_port($starttls);