File: 99_bugs.t

package info (click to toggle)
libdancer-perl 1.3521%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,460 kB
  • sloc: perl: 7,436; xml: 2,211; sh: 54; makefile: 32; sql: 5
file content (53 lines) | stat: -rw-r--r-- 1,339 bytes parent folder | download | duplicates (6)
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
52
53
use Test::More import => ['!pass'];
use strict;
use warnings;
use Dancer;
use Dancer::Test;

plan tests => 19;

# issue gh_77
{

    get '/:page' => sub {
        my $page = params->{page};
        return pass() unless $page =~ m/about|help|intro|upload/;
        return $page;
    };

    get '/status' => sub { 'status' };
    get '/search' => sub { 'search' };

    response_content_is [GET => '/intro'], 'intro';   # this work
    response_content_is [GET => '/status'], 'status'; # this is a 404, shouldn't
    response_content_is [GET => '/status'], 'status'; # now this work
    response_content_is [GET => '/search'], 'search'; # we get status here instead
    response_content_is [GET => '/search'], 'search'; # now this works
}


# issue gh_190
{
    my $i = 0;

    hook before => sub { redirect '/somewhere' if request->path eq '/' };
    get( '/', sub { $i++; 'Hello' } );

    route_exists [ GET => '/' ];
    response_headers_include [ GET => '/' ] => [ Location => 'http://localhost/somewhere' ];
    response_content_is      [ GET => '/' ] => '';
    is $i, 0;
}

# issue gh_393
# Test that vars are reset between each request by Dancer::Test
{
    var foo => 0;

    get '/reset' => sub { vars->{foo} += 1; vars->{foo}; };

    for ( 1 .. 10 ) {
        response_content_is [ GET => '/reset' ] => 1, "foo is 1";
    }
}