Commit | Line | Data |
c7ded7aa |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use FindBin; |
7 | use lib "$FindBin::Bin/lib"; |
8 | |
9 | use Test::More; |
10 | use Catalyst::Test 'TestApp'; |
11 | use Catalyst::Request; |
12 | use Config; |
13 | use HTTP::Response; |
14 | |
15 | plan skip_all => 'set TEST_THREADS to enable this test' |
16 | unless $ENV{TEST_THREADS}; |
17 | |
18 | if ( $Config{useithreads} && !$ENV{CATALYST_SERVER} ) { |
19 | require threads; |
20 | plan tests => 3; |
21 | } |
22 | else { |
23 | if ( $ENV{CATALYST_SERVER} ) { |
24 | plan skip_all => 'Using remote server'; |
25 | } |
26 | else { |
27 | plan skip_all => 'Needs a Perl with ithreads enabled'; |
28 | } |
29 | } |
30 | |
31 | no warnings 'redefine'; |
32 | sub request { |
33 | my $thr = threads->new( |
34 | sub { Catalyst::Test::local_request('TestApp',@_) }, |
35 | @_ |
36 | ); |
37 | $thr->join; |
38 | } |
39 | |
40 | # test that running inside a thread works ok |
41 | { |
42 | my @expected = qw[ |
43 | TestApp::Controller::Action::Default->begin |
44 | TestApp::Controller::Action::Default->default |
45 | TestApp::View::Dump::Request->process |
46 | TestApp->end |
47 | ]; |
48 | |
49 | my $expected = join( ", ", @expected ); |
50 | |
51 | ok( my $response = request('http://localhost/action/default'), 'Request' ); |
52 | ok( $response->is_success, 'Response Successful 2xx' ); |
53 | is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); |
54 | } |