Commit | Line | Data |
ee1e7faf |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use FindBin; |
7 | use lib "$FindBin::Bin/lib"; |
8 | |
9 | # Module::Build craps out on files with spaces so it's not included in the dist |
10 | my $has_space_file = -e "$FindBin::Bin/lib/TestApp/root/files/space file.txt"; |
11 | |
12 | use Test::More; |
4e8215c6 |
13 | plan tests => ($has_space_file) ? 12 : 9; |
ee1e7faf |
14 | use Catalyst::Test 'TestApp'; |
15 | |
16 | # test getting a css file |
17 | ok( my $res = request('http://localhost/files/static.css'), 'request ok' ); |
18 | is( $res->content_type, 'text/css', 'content-type text/css ok' ); |
19 | like( $res->content, qr/background/, 'content of css ok' ); |
20 | |
21 | # test a file with spaces |
22 | if ( $has_space_file ) { |
23 | ok( $res = request('http://localhost/files/space file.txt'), 'request ok' ); |
24 | is( $res->content_type, 'text/plain', 'content-type text/plain ok' ); |
25 | like( $res->content, qr/background/, 'content of space file ok' ); |
26 | } |
27 | |
28 | # test a non-existent file |
29 | ok( $res = request('http://localhost/files/404.txt'), 'request ok' ); |
30 | is( $res->content, 'default', 'default handler for non-existent content ok' ); |
31 | |
32 | # test unknown extension |
33 | ok( $res = request('http://localhost/files/err.omg'), 'request ok' ); |
34 | is( $res->content_type, 'text/plain', 'unknown extension as text/plain ok' ); |
4e8215c6 |
35 | |
36 | ok( $res = request('http://localhost/files/empty.txt'), 'request ok' ); |
37 | is( $res->content, '', 'empty files result in an empty response' ); |