Catalyst-Plugin-Static-File

 view release on metacpan or  search on metacpan

t/10-catalyst.t  view on Meta::CPAN


subtest "file" => sub {

    my $file = path($Bin)->child("static/hello.txt");

    my $res = request( GET '/?file=' . $file->basename );
    is $res->code,            HTTP_OK,            "status";
    is $res->content_type,    "text/plain",       "content_type";
    is $res->content_length,  $file->stat->size,  "content_length";
    is $res->last_modified,   $file->stat->mtime, "last_modified";
    is $res->decoded_content, $file->slurp_raw,   "content";
};

subtest "file with type" => sub {

    my $file = path($Bin)->child("static/hello.txt");

    my $res = request( GET '/?type=foo/bar&file=' . $file->basename );
    is $res->code,            HTTP_OK,            "status";
    is $res->content_type,    "foo/bar",          "content_type";
    is $res->content_length,  $file->stat->size,  "content_length";
    is $res->last_modified,   $file->stat->mtime, "last_modified";
    is $res->decoded_content, $file->slurp_raw,   "content";
};

subtest "bad file" => sub {

    my $file = path($Bin)->child("static/hello.txt.bad");

    my ( $res, $c ) = ctx_request( GET '/?file=' . $file->basename );
    is $res->code, HTTP_INTERNAL_SERVER_ERROR, "status (expected error)";

    my $abs = $file->absolute->canonpath;



( run in 0.426 second using v1.01-cache-2.11-cpan-26ccb49234f )