diff --git a/t/082-exceptions.rakutest b/t/082-exceptions.rakutest index d488859..e7fcaf9 100644 --- a/t/082-exceptions.rakutest +++ b/t/082-exceptions.rakutest @@ -3,16 +3,21 @@ use HTTP::UserAgent; plan 4; -my $ua = HTTP::UserAgent.new; -my $res; +if %*ENV { + my $ua = HTTP::UserAgent.new; + my $res; -lives-ok { $res = $ua.get('http://httpbin.org/status/404') }, "no exception - expect 404"; + lives-ok { $res = $ua.get('http://httpbin.org/status/404') }, "no exception - expect 404"; -ok !$res.is-success, "and it isn't successful"; -is $res.code, 404, "and a 404"; + ok !$res.is-success, "and it isn't successful"; + is $res.code, 404, "and a 404"; -$ua = HTTP::UserAgent.new(:throw-exceptions); + $ua = HTTP::UserAgent.new(:throw-exceptions); + + throws-like { $ua.get('http://httpbin.org/status/404') }, X::HTTP::Response, message => "Response error: '404 Not Found'", response => HTTP::Response; +} else { + skip-rest "NETWORK_TESTING not set won't do network tests"; +} -throws-like { $ua.get('http://httpbin.org/status/404') }, X::HTTP::Response, message => "Response error: '404 Not Found'", response => HTTP::Response; # vim: expandtab shiftwidth=4