File: http_status.t

package info (click to toggle)
libdancer2-perl 0.152000%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,820 kB
  • ctags: 536
  • sloc: perl: 8,034; sh: 51; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 1,424 bytes parent folder | download
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
use strict;
use warnings;
use Test::More tests => 11;

use Dancer2::Core::HTTP;

note "HTTP status"; {
    my @tests = (
        { status => undef,          expected => undef },
        { status => 200,            expected => 200   },
        { status => 'Not Found',    expected => 404   },
        { status => 'bad_request',  expected => 400   },
        { status => 'i_m_a_teapot', expected => 418   },
        { status => 'error',        expected => 500   },
        { status => 911,            expected => 911   },
    );

    for my $test (@tests) {
        my $status_text = defined $test->{status}
            ? $test->{status} : 'undef';
        is( Dancer2::Core::HTTP->status( $test->{status} ),
            $test->{expected},
            "HTTP status looks good for $status_text" );
    }
}


note "HTTP status_message"; {
    my @tests = (
        { status => undef,   expected => undef                   },
        { status => 200,     expected => 'OK'                    },
        { status => 'error', expected => 'Internal Server Error' },
        { status => 911,     expected => undef                   },
    );

    for my $test (@tests) {
        my $status_text = defined $test->{status}
            ? $test->{status} : 'undef';
        is( Dancer2::Core::HTTP->status_message( $test->{status} ),
            $test->{expected},
            "HTTP status message looks good for $status_text" );
    }
}