Changeset 16873
- Timestamp:
- 07/30/08 18:32:38 (5 years ago)
- Location:
- lang/perl/HTTP-Engine
- Files:
-
- 2 modified
-
branches/lazy_request/t/020_interface/test_upload.t (modified) (4 diffs)
-
trunk/t/020_interface/test_upload.t (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/HTTP-Engine/branches/lazy_request/t/020_interface/test_upload.t
r16846 r16873 5 5 use HTTP::Request; 6 6 use Test::Base; 7 use File::Temp qw( tempdir ); 8 use File::Spec; 7 9 8 plan tests => 1*blocks;10 plan tests => 3*blocks; 9 11 10 12 filters { … … 28 30 } 29 31 32 my $upload; 30 33 my $response = HTTP::Engine->new( 31 34 interface => { … … 36 39 $c->res->body('OK!'); 37 40 return unless $body; 38 return unless $c->req->upload('test_upload_file'); 39 unless ($body eq $c->req->upload('test_upload_file')->slurp) { 41 42 return unless $upload = $c->req->upload('test_upload_file'); 43 my $upload_body = $upload->slurp; 44 unless ($body eq $upload_body) { 40 45 $c->res->body('NG'); 41 46 } … … 47 52 my $data = $response->headers->as_string."\n".$response->content; 48 53 is $data, $block->response; 54 55 unless ($upload) { 56 ok 1; 57 ok 1; 58 return; 59 }; 60 61 my $tmpdir = tempdir( CLEANUP => 1 ); 62 is slurp( copy => $tmpdir => $upload ), $body; 63 is slurp( link => $tmpdir => $upload ), $body; 49 64 }; 65 66 sub slurp { 67 my($action, $tmpdir, $upload) = @_; 68 my $method = "${action}_to"; 69 my $path = File::Spec->catfile( $tmpdir, $action ); 70 $upload->$method($path); 71 open my $fh, '<', $path or die $!; 72 eval { local $/; <$fh> }; 73 } 50 74 51 75 sub crlf { -
lang/perl/HTTP-Engine/trunk/t/020_interface/test_upload.t
r16846 r16873 5 5 use HTTP::Request; 6 6 use Test::Base; 7 use File::Temp qw( tempdir ); 8 use File::Spec; 7 9 8 plan tests => 1*blocks;10 plan tests => 3*blocks; 9 11 10 12 filters { … … 28 30 } 29 31 32 my $upload; 30 33 my $response = HTTP::Engine->new( 31 34 interface => { … … 36 39 $c->res->body('OK!'); 37 40 return unless $body; 38 return unless $c->req->upload('test_upload_file'); 39 unless ($body eq $c->req->upload('test_upload_file')->slurp) { 41 42 return unless $upload = $c->req->upload('test_upload_file'); 43 my $upload_body = $upload->slurp; 44 unless ($body eq $upload_body) { 40 45 $c->res->body('NG'); 41 46 } … … 47 52 my $data = $response->headers->as_string."\n".$response->content; 48 53 is $data, $block->response; 54 55 unless ($upload) { 56 ok 1; 57 ok 1; 58 return; 59 }; 60 61 my $tmpdir = tempdir( CLEANUP => 1 ); 62 is slurp( copy => $tmpdir => $upload ), $body; 63 is slurp( link => $tmpdir => $upload ), $body; 49 64 }; 65 66 sub slurp { 67 my($action, $tmpdir, $upload) = @_; 68 my $method = "${action}_to"; 69 my $path = File::Spec->catfile( $tmpdir, $action ); 70 $upload->$method($path); 71 open my $fh, '<', $path or die $!; 72 eval { local $/; <$fh> }; 73 } 50 74 51 75 sub crlf {
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)