Fixed some typos
[catagits/Catalyst-Runtime.git] / t / live / component / controller / action / streaming.t
CommitLineData
fbcc39ad 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin;
7use lib "$FindBin::Bin/../../../lib";
8
d8c66af5 9use Test::More tests => 80;
fbcc39ad 10use Catalyst::Test 'TestApp';
11
d8c66af5 12for ( 1 .. 10 ) {
13
14 # test direct streaming
15 {
16 ok( my $response = request('http://localhost/streaming'), 'Request' );
17 ok( $response->is_success, 'Response Successful 2xx' );
18 is( $response->content_type, 'text/plain', 'Response Content-Type' );
19 is( $response->content,, <<'EOF', 'Content is a stream' );
fbcc39ad 20foo
21bar
22baz
23EOF
1775342a 24 }
d8c66af5 25
26 # test streaming by passing a handle to $c->res->body
27 SKIP:
28 {
29 if ( $ENV{CATALYST_SERVER} ) {
30 skip "Using remote server", 4;
31 }
32
33 my $file = "$FindBin::Bin/../../../../01use.t";
34 my $fh = IO::File->new( $file, 'r' );
35 my $buffer;
36 if ( defined $fh ) {
37 $fh->read( $buffer, 1024 );
38 $fh->close;
39 }
40
41 ok( my $response = request('http://localhost/action/streaming/body'),
42 'Request' );
43 ok( $response->is_success, 'Response Successful 2xx' );
44 is( $response->content_type, 'text/plain', 'Response Content-Type' );
45 is( $response->content, $buffer, 'Content is read from filehandle' );
3dc4d7e9 46 }
3dc4d7e9 47}