Skip to content

Commit ed20d6f

Browse files
committed
For [GH #124] [GH #117] - Add test for mount_psgi(/cgi-bin/, Plack::App::CGIBin).
1 parent 6e61ba3 commit ed20d6f

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

t/psgi.cgi-bin/test1.cgi

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env perl
2+
use strict;
3+
use warnings;
4+
5+
print "\n\n";
6+
print "QUERY_STRING: ", $ENV{QUERY_STRING} // '-', "\n";

t/psgi.d/cgi-bin/test1.cgi

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env perl
2+
use strict;
3+
use warnings;
4+
5+
print "\n\n";
6+
print "Under doc_root, QUERY_STRING: ", $ENV{QUERY_STRING} // '-', "\n";

t/psgi.t

+29-1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,34 @@ sub is_or_like($$;$) {
120120
, ": mnt2, not mnt. Longest must win.");
121121
}
122122

123+
{
124+
use Plack::Test;
125+
126+
# mount_psgi and PATH_INFO test.
127+
use Plack::App::CGIBin;
128+
# /cgi-bin outside of doc_root.
129+
$site->mount_psgi(
130+
"/cgi-bin/",
131+
Plack::App::CGIBin->new(root => "$rootname.cgi-bin")
132+
);
133+
134+
test_psgi $site->to_app, sub {
135+
my ($cb) = @_;
136+
my $res = $cb->(GET "/cgi-bin/test1.cgi?foo=bar");
137+
is $res->content, "\nQUERY_STRING: foo=bar\n";
138+
};
139+
140+
# /cgi-bin inside of doc_root.
141+
$site->mount_psgi(
142+
"/cgi-bin/",
143+
Plack::App::CGIBin->new(root => "$rootname.d/cgi-bin")
144+
);
145+
146+
test_psgi $site->to_app, sub {
147+
my ($cb) = @_;
148+
my $res = $cb->(GET "/cgi-bin/test1.cgi?x=y");
149+
is $res->content, "\nUnder doc_root, QUERY_STRING: x=y\n";
150+
};
123151
}
124152

125153
my $hello = sub {
@@ -306,7 +334,7 @@ END
306334
->to_app;
307335

308336
is_deeply [$backend->paths]
309-
, ['', qw|/beta /test.lib|]
337+
, ['', qw|/beta /cgi-bin /test.lib|]
310338
, "backend startup is called";
311339
}
312340

0 commit comments

Comments
 (0)