[Catalyst-commits] r8696 - in Catalyst-Runtime/5.80/trunk: . t/aggregate t/lib/TestApp/Controller t/lib/TestApp/View/Dump

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Wed Dec 3 09:08:59 GMT 2008


Author: t0m
Date: 2008-12-03 09:08:58 +0000 (Wed, 03 Dec 2008)
New Revision: 8696

Added:
   Catalyst-Runtime/5.80/trunk/t/lib/TestApp/View/Dump/Body.pm
Modified:
   Catalyst-Runtime/5.80/trunk/Changes
   Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_request_uploads.t
   Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Dump.pm
Log:
Add extra HTTP::Body tests I have had hanging around in my local repos for months

Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes	2008-12-03 08:55:34 UTC (rev 8695)
+++ Catalyst-Runtime/5.80/trunk/Changes	2008-12-03 09:08:58 UTC (rev 8696)
@@ -22,6 +22,8 @@
         - Change Catalyst::ClassData to tweak the symbol table inline for
           performance after profiling (mst)
         - Fix POD typo in finalize_error (jhannah)
+        - Add tests to ensure that we delete the temp files created by 
+          HTTP::Body's OctetStream parser (t0m)
 
 5.8000_03 2008-10-14 14:13:00
         - Fix forwarding to Catalyst::Action objects (Rafael Kitover).

Modified: Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_request_uploads.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_request_uploads.t	2008-12-03 08:55:34 UTC (rev 8695)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/live_engine_request_uploads.t	2008-12-03 09:08:58 UTC (rev 8696)
@@ -6,7 +6,7 @@
 use FindBin;
 use lib "$FindBin::Bin/../lib";
 
-use Test::More tests => 88;
+use Test::More tests => 96;
 use Catalyst::Test 'TestApp';
 
 use Catalyst::Request;
@@ -244,6 +244,41 @@
     }
 }
 
+# Test PUT request with application/octet-stream file gets deleted
+
+{
+    my $body;
+
+    my $request = PUT(
+        'http://localhost/dump/body/',
+        'Content-Type' => 'application/octet-stream',
+        'Content'      => 'foobarbaz',
+        'Content-Length' => 9,
+    );
+
+    ok( my $response = request($request), 'Request' );
+    ok( $response->is_success, 'Response Successful 2xx' );
+    is( $response->content_type, 'text/plain', 'Response Content-Type' );
+    like(
+       $response->content,
+       qr/bless\( .* 'HTTP::Body::OctetStream' \)/s,
+       'Content is a serialized HTTP::Body::OctetStream'
+    );
+
+    {
+        no strict 'refs';
+        ok(
+            eval '$body = ' . substr( $response->content, 8 ), # FIXME - substr not needed in other test cases?
+            'Unserialize HTTP::Body::OctetStream'
+        ) or warn $@;
+    }
+
+    isa_ok( $body, 'HTTP::Body::OctetStream' );
+    isa_ok($body->body, 'File::Temp');
+
+    ok( !-e $body->body->filename, 'Upload temp file was deleted' );
+}
+
 # test uploadtmp config var
 
 {

Modified: Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Dump.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Dump.pm	2008-12-03 08:55:34 UTC (rev 8695)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Dump.pm	2008-12-03 09:08:58 UTC (rev 8696)
@@ -29,4 +29,9 @@
     $c->forward('TestApp::View::Dump::Response');
 }
 
+sub body : Action Relative {
+    my ( $self, $c ) = @_;
+    $c->forward('TestApp::View::Dump::Body');
+}
+
 1;

Added: Catalyst-Runtime/5.80/trunk/t/lib/TestApp/View/Dump/Body.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestApp/View/Dump/Body.pm	                        (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestApp/View/Dump/Body.pm	2008-12-03 09:08:58 UTC (rev 8696)
@@ -0,0 +1,11 @@
+package TestApp::View::Dump::Body;
+
+use strict;
+use base qw[TestApp::View::Dump];
+
+sub process {
+    my ( $self, $c ) = @_;
+    return $self->SUPER::process( $c, $c->request->{_body} ); # FIXME, accessor doesn't work?
+}
+
+1;




More information about the Catalyst-commits mailing list