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 BF41A1FC9B for ; Mon, 15 Mar 2021 11:58:29 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 14/35] t/altid: use create_inbox Date: Mon, 15 Mar 2021 12:58:05 +0100 Message-Id: <20210315115826.17591-15-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: Another few dozen milliseconds saved. --- t/altid.t | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/t/altid.t b/t/altid.t index 0e9da07e..87635b19 100644 --- a/t/altid.t +++ b/t/altid.t @@ -1,15 +1,13 @@ +#!perl -w # Copyright (C) 2016-2021 all contributors # License: AGPL-3.0+ use strict; -use warnings; -use Test::More; +use v5.10.1; use PublicInbox::TestCommon; use PublicInbox::Eml; require_mods(qw(DBD::SQLite Search::Xapian)); use_ok 'PublicInbox::Msgmap'; use_ok 'PublicInbox::SearchIdx'; -use_ok 'PublicInbox::Import'; -use_ok 'PublicInbox::Inbox'; my ($tmpdir, $for_destroy) = tmpdir(); my $git_dir = "$tmpdir/a.git"; my $alt_file = "$tmpdir/another-nntp.sqlite3"; @@ -24,10 +22,9 @@ my $ibx; } { - my $git = PublicInbox::Git->new($git_dir); - my $im = PublicInbox::Import->new($git, 'testbox', 'test@example'); - $im->init_bare; - $im->add(PublicInbox::Eml->new(<<'EOF')); + $ibx = create_inbox 'testbox', tmpdir => $git_dir, sub { + my ($im) = @_; + $im->add(PublicInbox::Eml->new(<<'EOF')); From: a@example.com To: b@example.com Subject: boo! @@ -35,13 +32,9 @@ Message-ID: hello world gmane:666 EOF - $im->done; -} -{ - $ibx = PublicInbox::Inbox->new({inboxdir => $git_dir}); + }; $ibx->{altid} = $altid; - my $rw = PublicInbox::SearchIdx->new($ibx, 1); - $rw->index_sync; + PublicInbox::SearchIdx->new($ibx, 1)->index_sync; } { @@ -60,7 +53,4 @@ EOF my $num = $mm->mid_insert('b@example.com'); ok($num > $max, 'auto-increment goes beyond mid_set'); } - -done_testing(); - -1; +done_testing;