-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweather-tests.pl
28 lines (21 loc) · 1.13 KB
/
weather-tests.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use strict;
use warnings;
use lib './lib/';
use Test::More tests => 6;
use Plack::Test;
use HTTP::Request::Common;
use Weather;
my $test = Plack::Test->create( Weather->to_app );
my $response = $test->request( GET '/' );
ok( $response->is_success, '[GET /] Successful request' );
like( $response->content, qr/"response":/, '[GET /] Correct content' );
$response = $test->request( GET '/?url=http://www.google.com/' );
like( $response->content, qr/"error":/, '[GET /?url=http://www.google.com] Correct error content' );
$response = $test->request( GET '/?url=http://www.bom.gov.au/invaliddirname/IDN60801/IDN60801.95765.json' );
is( $response->content, '{"error":"404 Not Found"}', '[GET /?url=http://www.bom.gov.au/invaliddirname/IDN60801/IDN60801.95765.json] Correct error content' );
$response = `curl -s http://weather.johnhorner.info`;
like( $response, qr/"response":/, 'curl request to HTTP URL' );
# TODO: there's an issue with the certificate so we need to run with the -k switch, which is insecure
$response = `curl -k -s https://weather.johnhorner.info`;
like( $response, qr/"response":/, 'curl request to HTTPS URL' );
done_testing();