summaryrefslogtreecommitdiff
path: root/cpan/HTTP-Tiny
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-12-11 20:38:11 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-12-11 20:40:51 -0800
commit89315372d63ea563aa813875881630eae4595e39 (patch)
tree03b28687062fc9e73e861484cf3a013c9cdbd8a0 /cpan/HTTP-Tiny
parent1cbe4e6fdc25527a4e9930e2f6a96fea3834bfd1 (diff)
downloadperl-89315372d63ea563aa813875881630eae4595e39.tar.gz
Ignore proxies in HTTP::Tiny tests
I have HTTP_PROXY and http_proxy set. HTTP::Tiny just gained HTTP_PROXY capabilities, and all the tests fail, because they were only masking http_proxy, not HTTP_PROXY. Reported at https://github.com/chansen/p5-http-tiny/issues/60.
Diffstat (limited to 'cpan/HTTP-Tiny')
-rw-r--r--cpan/HTTP-Tiny/t/140_proxy.t16
-rw-r--r--cpan/HTTP-Tiny/t/Util.pm4
2 files changed, 11 insertions, 9 deletions
diff --git a/cpan/HTTP-Tiny/t/140_proxy.t b/cpan/HTTP-Tiny/t/140_proxy.t
index a23568ec98..2432fed2fb 100644
--- a/cpan/HTTP-Tiny/t/140_proxy.t
+++ b/cpan/HTTP-Tiny/t/140_proxy.t
@@ -12,6 +12,7 @@ use HTTP::Tiny;
for my $proxy (undef, "", 0){
local $ENV{all_proxy} = undef;
local $ENV{ALL_PROXY} = undef;
+ local $ENV{HTTP_PROXY} = $proxy;
local $ENV{http_proxy} = $proxy;
my $c = HTTP::Tiny->new();
ok(!defined $c->http_proxy);
@@ -49,18 +50,19 @@ for my $proxy ("http://localhost:8080/", "http://localhost:8080"){
}
# case variations
-for my $var ( qw/http_proxy https_proxy all_proxy/ ) {
+my @vars = map +(uc, lc), qw/http_proxy https_proxy all_proxy/;
+for my $var ( @vars ) {
my $proxy = "http://localhost:8080";
- for my $s ( uc($var), lc($var) ) {
- local $ENV{$s} = $proxy;
- my $c = HTTP::Tiny->new();
- my $m = ($s =~ /all/i) ? 'proxy' : lc($s);
- is( $c->$m, $proxy, "set $m from $s" );
- }
+ local @ENV{@vars};
+ local $ENV{$var} = $proxy;
+ my $c = HTTP::Tiny->new();
+ my $m = ($var =~ /all/i) ? 'proxy' : lc($var);
+ is( $c->$m, $proxy, "set $m from $var" );
}
# ignore HTTP_PROXY with REQUEST_METHOD
{
+ local $ENV{http_proxy};
local $ENV{HTTP_PROXY} = "http://localhost:8080";
local $ENV{REQUEST_METHOD} = 'GET';
my $c = HTTP::Tiny->new();
diff --git a/cpan/HTTP-Tiny/t/Util.pm b/cpan/HTTP-Tiny/t/Util.pm
index 6698bdcfff..717eaa765a 100644
--- a/cpan/HTTP-Tiny/t/Util.pm
+++ b/cpan/HTTP-Tiny/t/Util.pm
@@ -169,8 +169,8 @@ sub sort_headers {
*HTTP::Tiny::Handle::close = sub { 1 }; # don't close our temps
# don't try to proxy in mock-mode
- delete $ENV{http_proxy};
- delete $ENV{$_} for map { $_, uc($_) } qw/https_proxy all_proxy/;
+ delete $ENV{$_}
+ for map { $_, uc($_) } qw/http_proxy https_proxy all_proxy/;
}
}