]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
t/feed: fix uninitialized variable warnings
authorEric Wong <e@80x24.org>
Mon, 16 Sep 2024 09:53:59 +0000 (09:53 +0000)
committerEric Wong <e@80x24.org>
Mon, 16 Sep 2024 21:00:28 +0000 (21:00 +0000)
These warnings only happened under test conditions and never
when running under any PSGI servers.  In retrospect, t/feed.t is
likely redundant nowadays and ought to be folded into existing
PSGI tests so we don't have to consider setup problems like
these.

Fixes: bbe582cdfa429 ("view: fix addr2urlmap with Plack::Builder::mount")
t/feed.t

index cc5ae277f7c1e397b59e98429aff85c87badfc50..8e80b531e489b863a85a4159a15c33dd5c8f1858 100644 (file)
--- a/t/feed.t
+++ b/t/feed.t
@@ -1,5 +1,5 @@
 #!perl -w
-# Copyright (C) 2014-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use v5.10.1;
@@ -10,17 +10,6 @@ use PublicInbox::Inbox;
 my $have_xml_treepp = eval { require XML::TreePP; 1 };
 my ($tmpdir, $for_destroy) = tmpdir();
 
-sub string_feed {
-       my $res = PublicInbox::Feed::generate($_[0]);
-       my $body = $res->[2];
-       my $str = '';
-       while (defined(my $chunk = $body->getline)) {
-               $str .= $chunk;
-       }
-       $body->close;
-       $str;
-}
-
 my $git_dir = "$tmpdir/gittest";
 my $ibx = create_inbox 'v1', tmpdir => $git_dir, sub {
        my ($im, $ibx) = @_;
@@ -46,13 +35,28 @@ EOF
 
 $ibx->{url} = [ 'http://example.com/test' ];
 $ibx->{feedmax} = 3;
+my $ctx = {
+       ibx => $ibx,
+       env => { HTTP_HOST => 'example.com', 'psgi.url_scheme' => 'http' },
+};
+my $string_feed = sub {
+       my $res = PublicInbox::Feed::generate($ctx);
+       my $body = $res->[2];
+       my $str = '';
+       while (defined(my $chunk = $body->getline)) {
+               $str .= $chunk;
+       }
+       $body->close;
+       $str;
+};
+
 my $im = $ibx->importer(0);
 
 # spam check
 {
        # check initial feed
        {
-               my $feed = string_feed({ ibx => $ibx });
+               my $feed = $string_feed->();
                SKIP: {
                        skip 'XML::TreePP missing', 3 unless $have_xml_treepp;
                        my $t = XML::TreePP->new->parse($feed);
@@ -86,7 +90,7 @@ EOF
 
        # check spam shows up
        {
-               my $spammy_feed = string_feed({ ibx => $ibx });
+               my $spammy_feed = $string_feed->();
                SKIP: {
                        skip 'XML::TreePP missing', 2 unless $have_xml_treepp;
                        my $t = XML::TreePP->new->parse($spammy_feed);
@@ -104,7 +108,7 @@ EOF
 
        # spam no longer shows up
        {
-               my $feed = string_feed({ ibx => $ibx });
+               my $feed = $string_feed->();
                SKIP: {
                        skip 'XML::TreePP missing', 2 unless $have_xml_treepp;
                        my $t = XML::TreePP->new->parse($feed);