new test to make sure people using legacy psgi engine who do not upgrade their psgi...
John Napiorkowski [Fri, 22 Jul 2011 04:47:46 +0000 (00:47 -0400)]
Makefile.PL
t/psgi_file_testapp_engine_plackup_compat.t [new file with mode: 0644]

index 7a91b92..1d291f7 100644 (file)
@@ -63,6 +63,7 @@ test_requires 'Class::Data::Inheritable';
 test_requires 'Test::Exception';
 test_requires 'Test::More' => '0.88';
 test_requires 'Data::Dump';
+test_requires 'HTTP::Request::Common';
 
 # aggregate tests if AGGREGATE_TESTS is set and a recent Test::Aggregate and a Test::Simple it works with is available
 if ($ENV{AGGREGATE_TESTS} && can_use('Test::Simple', '0.88') && can_use('Test::Aggregate', '0.364')) {
diff --git a/t/psgi_file_testapp_engine_plackup_compat.t b/t/psgi_file_testapp_engine_plackup_compat.t
new file mode 100644 (file)
index 0000000..54fdabb
--- /dev/null
@@ -0,0 +1,37 @@
+use strict;
+use warnings;
+use FindBin qw/$Bin/;
+use lib "$Bin/lib";
+
+use Test::More;
+use Plack::Test;
+use TestApp;
+use HTTP::Request::Common;
+
+my $warning;
+local $SIG{__WARN__} = sub { $warning = $_[0] };
+
+TestApp->setup_engine('PSGI');
+my $app = sub { TestApp->run(@_) };
+
+like $warning, qr/You are running Catalyst\:\:Engine\:\:PSGI/,
+  'got deprecation alert warning';
+
+test_psgi $app, sub {
+    my $cb = shift;
+    eval {
+        my $TIMEOUT_IN_SECONDS = 5;
+        local $SIG{ALRM} = sub { die "alarm\n" };
+        alarm($TIMEOUT_IN_SECONDS);
+
+        my $res = $cb->(GET "/");
+        is $res->content, "root index", 'got expected content';
+        like $warning, qr/env as a writer/, 'got deprecation alert warning';
+
+        alarm(0);
+        1
+    } || fail "$@ problem";
+};
+
+done_testing;
+