I think Test::Exception is a little better here
[catagits/Catalyst-Runtime.git] / t / psgi_file_testapp_engine_plackup_compat.t
1 use strict;
2 use warnings;
3 use FindBin qw/$Bin/;
4 use lib "$Bin/lib";
5
6 use Test::More;
7 use Test::Exception;
8 use Plack::Test;
9 use TestApp;
10 use HTTP::Request::Common;
11
12 my $warning;
13 local $SIG{__WARN__} = sub { $warning = $_[0] };
14
15 TestApp->setup_engine('PSGI');
16 my $app = sub { TestApp->run(@_) };
17
18 like $warning, qr/You are running Catalyst\:\:Engine\:\:PSGI/,
19   'got deprecation alert warning';
20
21 test_psgi $app, sub {
22     my $cb = shift;
23     lives_ok {
24         my $TIMEOUT_IN_SECONDS = 5;
25         local $SIG{ALRM} = sub { die "alarm\n" };
26         alarm($TIMEOUT_IN_SECONDS);
27
28         my $res = $cb->(GET "/");
29         is $res->content, "root index", 'got expected content';
30         like $warning, qr/env as a writer/, 'got deprecation alert warning';
31
32         alarm(0);
33         1
34     } q{app didn't die or timeout};
35 };
36
37 done_testing;
38