Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to using subtests per issue #1520 #1832

Merged
merged 4 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions t/mojo/proxy.t
Original file line number Diff line number Diff line change
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();
Loading