Skip to content

Commit

Permalink
Merge pull request #1832 from petdance/subtests
Browse files Browse the repository at this point in the history
Convert to using subtests per issue #1520
  • Loading branch information
mergify[bot] committed Aug 13, 2021
2 parents 29fc0f3 + e1e706a commit ee8b44e
Show file tree
Hide file tree
Showing 4 changed files with 394 additions and 357 deletions.
14 changes: 11 additions & 3 deletions t/mojo/proxy.t
Expand Up @@ -4,7 +4,7 @@ use Test::More;
use Mojo::UserAgent::Proxy;

# Proxy detection
{
subtest 'Proxy detection with uppercase variable names' => sub {
my $proxy = Mojo::UserAgent::Proxy->new;
local $ENV{HTTP_PROXY} = 'http://127.0.0.1';
local $ENV{HTTPS_PROXY} = 'http://127.0.0.1:8080';
Expand All @@ -19,10 +19,18 @@ use Mojo::UserAgent::Proxy;
ok !$proxy->is_needed('dummy.mojolicious.org'), 'no proxy needed';
ok $proxy->is_needed('icious.org'), 'proxy needed';
ok $proxy->is_needed('localhost'), 'proxy needed';
($ENV{HTTP_PROXY}, $ENV{HTTPS_PROXY}, $ENV{NO_PROXY}) = ();
};

subtest 'Proxy detection with lowercase variable names' => sub {
local $ENV{HTTP_PROXY};
local $ENV{HTTPS_PROXY};
local $ENV{NO_PROXY};

local $ENV{http_proxy} = 'proxy.example.com';
local $ENV{https_proxy} = 'tunnel.example.com';
local $ENV{no_proxy} = 'localhost,localdomain,foo.com,example.com';

my $proxy = Mojo::UserAgent::Proxy->new;
$proxy->detect;
is_deeply $proxy->not, ['localhost', 'localdomain', 'foo.com', 'example.com'], 'right list';
is $proxy->http, 'proxy.example.com', 'right proxy';
Expand All @@ -35,6 +43,6 @@ use Mojo::UserAgent::Proxy;
ok !$proxy->is_needed('example.com'), 'no proxy needed';
ok !$proxy->is_needed('www.example.com'), 'no proxy needed';
ok $proxy->is_needed('www.example.com.com'), 'proxy needed';
}
};

done_testing();

0 comments on commit ee8b44e

Please sign in to comment.