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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#!perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use Test::More 0.88;
use Catalyst::Test 'TestApp';
run_tests();
done_testing;
sub run_tests {
# test first available view
{
my $expected = 'View';
my $request =
HTTP::Request->new( GET => 'http://localhost:3000/test_firstview' );
ok( my $response = request($request), 'Request' );
ok( $response->is_success, 'Response Successful 2xx' );
is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' );
is( $response->code, 200, 'Response Code' );
is( $response->content, $expected, 'Content OK' );
}
# test view
{
my $expected = 'View';
my $request =
HTTP::Request->new( GET => 'http://localhost:3000/test_view' );
ok( my $response = request($request), 'Request' );
ok( $response->is_success, 'Response Successful 2xx' );
is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' );
is( $response->code, 200, 'Response Code' );
is( $response->content, $expected, 'Content OK' );
}
# test skip view
{
my $expected = 'Skipped View';
my $request =
HTTP::Request->new( GET => 'http://localhost:3000/test_skipview' );
ok( my $response = request($request), 'Request' );
ok( $response->is_success, 'Response Successful 2xx' );
is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' );
is( $response->code, 200, 'Response Code' );
is( $response->content, $expected, 'Content OK' );
}
# test X-Sendfile case
{
my $request =
HTTP::Request->new( GET => 'http://localhost:3000/test_definedbody_skipsview' );
ok( my $response = request($request), 'Request' );
ok( $response->is_success, 'Response Successful 2xx' );
is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' );
is( $response->code, 200, 'Response Code' );
is( $response->content, '', 'Content OK' );
is( $response->header('X-Sendfile'), '/some/file/path', 'X-Sendfile header present' );
}
}
|