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