File: mime.t

package info (click to toggle)
libdancer2-perl 1.1.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,648 kB
  • sloc: perl: 8,589; makefile: 9
file content (44 lines) | stat: -rw-r--r-- 1,017 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use strict;
use warnings;
use Test::More tests => 2;
use Plack::Test;
use HTTP::Request::Common;

{
    package App::MIME;
    use Dancer2;

    # set some MIME aliases...
    mime->add_type( foo => 'text/foo' );
    mime->add_alias( f => 'foo' );

    # Set default mime type
    set 'default_mime_type' => 'text/bar';

    # test static corpus
    set static_handler => 1;
    set public_dir => 't/corpus/static';

    # added type
    get '/foo' => sub {
        send_file 'empty.foo';
    };

}

my $app = Plack::Test->create( App::MIME->to_app );


subtest 'send_file content type' => sub {
    my $res = $app->request( GET '/foo' );
    ok( $res->is_success, 'Successful request' );
    is( $res->content_type, 'text/foo', '.. and correct mime type');
    
};

# Ref: #1546
subtest 'static handler content type' => sub {
    my $res = $app->request( GET '/empty.foo' );
    ok( $res->is_success, 'Successful request via static handler' );
    is( $res->content_type, 'text/foo', '.. and correct mime type');
};