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 5EDDD1FC99 for ; Mon, 15 Mar 2021 11:58:29 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 12/35] t/httpd: convert to create_inbox Date: Mon, 15 Mar 2021 12:58:03 +0100 Message-Id: <20210315115826.17591-13-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: No real difference, here, but having less code is nice. --- t/httpd.t | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/t/httpd.t b/t/httpd.t index af9fbfeb..0354a733 100644 --- a/t/httpd.t +++ b/t/httpd.t @@ -1,8 +1,8 @@ +#!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; use Socket qw(IPPROTO_TCP SOL_SOCKET); @@ -13,22 +13,15 @@ my ($tmpdir, $for_destroy) = tmpdir(); my $home = "$tmpdir/pi-home"; my $err = "$tmpdir/stderr.log"; my $out = "$tmpdir/stdout.log"; -my $maindir = "$tmpdir/main.git"; +my $inboxdir = "$tmpdir/i.git"; my $group = 'test-httpd'; my $addr = $group . '@example.com'; -my $cfgpfx = "publicinbox.$group"; my $sock = tcp_server(); my $td; -use_ok 'PublicInbox::Git'; -use_ok 'PublicInbox::Import'; { - local $ENV{HOME} = $home; - my $cmd = [ '-init', $group, $maindir, 'http://example.com/', $addr ]; - ok(run_script($cmd), 'init ran properly'); - - # ensure successful message delivery - { - my $mime = PublicInbox::Eml->new(< $inboxdir, sub { + my ($im, $ibx) = @_; + $im->add(PublicInbox::Eml->new(< To: You Cc: $addr @@ -38,12 +31,10 @@ Date: Thu, 01 Jan 1970 06:06:06 +0000 nntp EOF - - my $git = PublicInbox::Git->new($maindir); - my $im = PublicInbox::Import->new($git, 'test', $addr); - $im->add($mime); - $im->done($mime); - } + }; + local $ENV{HOME} = $home; + my $cmd = [ '-init', $group, $inboxdir, 'http://example.com/', $addr ]; + ok(run_script($cmd), 'init ran properly'); $cmd = [ '-httpd', '-W0', "--stdout=$out", "--stderr=$err" ]; $td = start_script($cmd, undef, { 3 => $sock }); my $http_pfx = 'http://'.tcp_host_port($sock); @@ -53,7 +44,6 @@ EOF like(<$bad>, qr!\AHTTP/1\.[01] 405\b!, 'got 405 on bad req'); } my $conn = tcp_connect($sock); - ok($conn, 'connected'); ok($conn->write("GET / HTTP/1.0\r\n\r\n"), 'wrote data to socket'); { my $buf; @@ -67,7 +57,7 @@ EOF 0, 'smart clone successful'); # ensure dumb cloning works, too: - is(xsys('git', "--git-dir=$maindir", + is(xsys('git', "--git-dir=$inboxdir", qw(config http.uploadpack false)), 0, 'disable http.uploadpack'); is(xsys(qw(git clone -q --mirror), @@ -99,6 +89,4 @@ SKIP: { like($x, qr/\Ahttpready\0+\z/, 'got httpready accf for HTTP'); }; -done_testing(); - -1; +done_testing;