X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Faggregate%2Flive_engine_request_uploads.t;h=5ba8f1858cc238bc9bf0969b82f012acf6b162b6;hb=c463b49c849c28a6fa46e9eb1c07a31b51696f1d;hp=47913dbbec9f6727bfd17cc43c640bdd0730325f;hpb=ad51fa70a7d26981b1da0dabdc1e193ade38f3d7;p=catagits%2FCatalyst-Runtime.git diff --git a/t/aggregate/live_engine_request_uploads.t b/t/aggregate/live_engine_request_uploads.t index 47913db..5ba8f18 100644 --- a/t/aggregate/live_engine_request_uploads.t +++ b/t/aggregate/live_engine_request_uploads.t @@ -1,14 +1,12 @@ -#!perl - use strict; use warnings; use FindBin; use lib "$FindBin::Bin/../lib"; -use Test::More tests => 101; +use Test::More tests => 105; use Catalyst::Test 'TestApp'; - +use Scalar::Util qw/ blessed /; use Catalyst::Request; use Catalyst::Request::Upload; use HTTP::Body::OctetStream; @@ -134,6 +132,7 @@ use Path::Class::Dir; is( $upload->type, $part->content_type, 'Upload Content-Type' ); is( $upload->filename, $parameters{filename}, 'Upload filename' ); is( $upload->size, length( $part->content ), 'Upload Content-Length' ); + is( $upload->basename, $parameters{filename}, 'Upload basename' ); SKIP: { @@ -196,9 +195,17 @@ use Path::Class::Dir; 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/file1 => bless/, 'Upload with name file1'); - like( $response->content, qr/file2 => bless/, 'Upload with name file2'); - + { + local $@; + my $request = eval $response->content; + if ($@) { + fail("Could not inflate response: $@ " . $response->content); + } + else { + ok blessed($request->uploads->{file1}), 'Upload with name file1'; + ok blessed($request->uploads->{file2}),'Upload with name file2'; + } + } my $creq; { no strict 'refs'; @@ -276,6 +283,7 @@ use Path::Class::Dir; is( $upload->type, $part->content_type, 'Upload Content-Type' ); is( $upload->size, length( $part->content ), 'Upload Content-Length' ); is( $upload->filename, 'catalyst_130pix.gif', 'Upload Filename' ); + is( $upload->basename, 'catalyst_130pix.gif', 'Upload basename' ); SKIP: { @@ -324,6 +332,14 @@ use Path::Class::Dir; if ( $ENV{CATALYST_SERVER} ) { skip 'Not testing for deleted file on remote server', 1; } + + # JNAP, I added the following line in order to properly let + # the $env go out of scope so that the associated tempfile + # would be deleted. I think somewhere Catalyst::Test closed + # over ENV and holds state until a new command is issues but + # I can't find it. + + request GET 'http://localhost/'; ok( !-e $body->body->filename, 'Upload temp file was deleted' ); } }