Commit | Line | Data |
50cc3183 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use FindBin; |
42da66a9 |
5 | use lib "$FindBin::Bin/../lib"; |
50cc3183 |
6 | |
7 | my $content = q/foo |
8 | bar |
9 | baz |
10 | /; |
11 | |
12 | our $iters; |
13 | |
6b25e555 |
14 | BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } |
50cc3183 |
15 | |
16 | use Test::More tests => 16*$iters; |
17 | use Catalyst::Test 'TestApp'; |
18 | |
19 | if ( $ENV{CAT_BENCHMARK} ) { |
20 | require Benchmark; |
21 | Benchmark::timethis( $iters, \&run_tests ); |
22 | } |
23 | else { |
24 | for ( 1 .. $iters ) { |
dcac0a27 |
25 | run_tests($content); |
50cc3183 |
26 | } |
27 | } |
28 | |
29 | sub run_tests { |
dcac0a27 |
30 | my ($content) = @_; |
31 | |
50cc3183 |
32 | # Local |
33 | { |
34 | ok( |
35 | my $response = |
36 | request('http://localhost/action/multipath/multipath'), |
37 | 'Request' |
38 | ); |
39 | ok( $response->is_success, 'Response Successful 2xx' ); |
40 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
41 | is( $response->content, $content, 'Content is a stream' ); |
42 | } |
43 | |
44 | # Global |
45 | { |
46 | ok( my $response = request('http://localhost/multipath'), 'Request' ); |
47 | ok( $response->is_success, 'Response Successful 2xx' ); |
48 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
49 | is( $response->content, $content, 'Content is a stream' ); |
50 | } |
51 | |
52 | # Path('/multipath1') |
53 | { |
54 | ok( my $response = request('http://localhost/multipath1'), 'Request' ); |
55 | ok( $response->is_success, 'Response Successful 2xx' ); |
56 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
57 | is( $response->content, $content, 'Content is a stream' ); |
58 | } |
59 | |
60 | # Path('multipath2') |
61 | { |
62 | ok( |
63 | my $response = |
64 | request('http://localhost/action/multipath/multipath2'), |
65 | 'Request' |
66 | ); |
67 | ok( $response->is_success, 'Response Successful 2xx' ); |
68 | is( $response->content_type, 'text/plain', 'Response Content-Type' ); |
69 | is( $response->content, $content, 'Content is a stream' ); |
70 | } |
71 | } |