File: response.t

package info (click to toggle)
libplack-perl 0.9989-1%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,556 kB
  • sloc: perl: 6,890; python: 6; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,170 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
45
46
47
48
49
50
51
use strict;
use warnings;
use Test::More;
use Plack::Response;

sub res {
    my $res = Plack::Response->new;
    my %v = @_;
    while (my($k, $v) = each %v) {
        $res->$k($v);
    }
    $res->finalize;
}

is_deeply(
    res(
        status => 200,
        body => 'hello',
    ),
    [ 200, +[], [ 'hello' ] ]
);
is_deeply(
    res(
        status => 200,
        cookies => +{
            'foo_sid' => +{
                value => 'ASDFJKL:',
                expires => 'Thu, 25-Apr-1999 00:40:33 GMT',
                domain  => 'example.com',
                path => '/',
            },
            'poo_sid' => +{
                value => 'QWERTYUI',
                expires => 'Thu, 25-Apr-1999 00:40:33 GMT',
                domain  => 'example.com',
                path => '/',
            },
        },
        body   => 'hello',
    ),
    [
        200,
        +[
            'Set-Cookie' => 'poo_sid=QWERTYUI; domain=example.com; path=/; expires=Thu, 25-Apr-1999 00:40:33 GMT',
            'Set-Cookie' => 'foo_sid=ASDFJKL%3A; domain=example.com; path=/; expires=Thu, 25-Apr-1999 00:40:33 GMT',
        ],
        [ 'hello' ],
    ]
);

done_testing;