Add PerlIO methods to Catalyst::Response, so that it more properly
[catagits/Catalyst-Runtime.git] / t / aggregate / live_engine_response_perlio.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use FindBin;
7 use lib "$FindBin::Bin/../lib";
8
9 use Test::More;
10 use Catalyst::Test 'TestApp';
11
12 my $types = {
13     #zip => ['Archive::Zip',  464, qr/^PK\x03\x04.*[\x80-\xFF]+.*x.txt/s],
14     ### Archive::Zip currently unreliable as a test platform until RT #54827 is fixed and popularized ###
15     ### https://rt.cpan.org/Ticket/Display.html?id=54827 ###
16     
17     csv => ['Text::CSV',      96, qr/"Banana \(single\)","\$ \.40"$/m],
18     xml => ['XML::Simple',  1657, qr(</geocode>)],
19 };
20
21 plan tests => scalar keys %$types;
22
23 for my $action ( keys %$types ) {
24     my ($module, $length, $regexp) = @{$types->{$action}};
25     
26     subtest uc($action)." Set" => sub {
27         undef $@;
28         eval "require $module";  # require hates string class names; must use eval string instead of block
29         print $@;
30         plan ($@ ? (skip_all => $module.' not installed') : (tests => 4) );
31     
32         ok( my $response = request('http://localhost/engine/response/perlio/' . $action ), "Request" );
33         ok( $response->is_success, "Response Successful 2xx" );
34         is( length( $response->content ), $length, "Length OK" );
35         like( $response->content, $regexp, "RegExp Check OK" );
36         done_testing();
37     };
38 }
39
40 done_testing();