From: John Napiorkowski Date: Mon, 1 Dec 2014 23:33:22 +0000 (-0600) Subject: troubling test results X-Git-Tag: 5.90079_001~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=59e11cd702fecaabe37167918a79c4c62f935acb troubling test results --- diff --git a/t/utf8.txt b/t/utf8.txt new file mode 100644 index 0000000..484d2cb --- /dev/null +++ b/t/utf8.txt @@ -0,0 +1 @@ +

This is stream_body_fh action ♥

diff --git a/t/utf_incoming.t b/t/utf_incoming.t index f556bf7..b743830 100644 --- a/t/utf_incoming.t +++ b/t/utf_incoming.t @@ -3,6 +3,8 @@ use warnings; use strict; use Test::More; use HTTP::Request::Common; +use Encode 2.21 'decode_utf8', 'encode_utf8'; +use File::Spec; # Test cases for incoming utf8 @@ -80,8 +82,17 @@ use HTTP::Request::Common; my $writer = $c->res->write_fh; - $writer->write("

This is stream_write_fh action ♥

"); - $writer->close("

This is stream_write_fh action ♥

"); + $writer->write(Encode::encode_utf8('

This is stream_write_fh action ♥

')); + $writer->close; + } + + sub stream_body_fh :Local { + my ($self, $c) = @_; + + my $path = File::Spec->catfile('t', 'utf8.txt'); + open(my $fh, '<', $path) || die "trouble: $!"; + $c->response->content_type('text/html'); + $c->response->body($fh); } package MyApp; @@ -95,7 +106,6 @@ use HTTP::Request::Common; ok my $psgi = MyApp->psgi_app, 'build psgi app'; use Catalyst::Test 'MyApp'; -use Encode 2.21 'decode_utf8', 'encode_utf8'; { my $res = request "/root/♥"; @@ -202,10 +212,20 @@ use Encode 2.21 'decode_utf8', 'encode_utf8'; } { - my $res = request "/root/stream_write_fh"; + my $res = request "/root/stream_body_fh"; + + is $res->code, 200, 'OK'; + is decode_utf8($res->content), "

This is stream_body_fh action ♥

\n", 'correct body'; + # Not sure why there is a trailing newline above... its not in catalyst code I can see. Not sure + # if is a problem or just an artifact of the why the test stuff works - JNAP +} + +{ + my $res = request "/root/stream_write_fh"; is $res->code, 200, 'OK'; is decode_utf8($res->content), '

This is stream_write_fh action ♥

', 'correct body'; } + done_testing;