File: 002_valid_entry_points.t

package info (click to toggle)
libcgi-application-server-perl 0.062-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 164 kB
  • ctags: 23
  • sloc: perl: 548; makefile: 4
file content (70 lines) | stat: -rw-r--r-- 1,504 bytes parent folder | download | duplicates (4)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 22;
use Test::Exception;

BEGIN {
    use_ok('CGI::Application::Server');
}

=pod

This could probably use some more tests, but it 
is good enough for now (i.e. - covers the bug 
which prompted this fix)

=cut

my $server = CGI::Application::Server->new();
isa_ok($server, 'CGI::Application::Server');
isa_ok($server, 'HTTP::Server::Simple');

$server->entry_points({
    '/foo'         => 'Foo',
    '/foo/bar'     => 'Foo::Bar',    
    '/foo/bar/baz' => 'Foo::Bar::Baz',    
});

foreach my $uri (qw(
        /foo
        /foo?say=hello
        /foo/bling/bar
        /foo/?bar=baz
        /foo/barr
    )) {
    is($server->is_valid_entry_point($uri), 'Foo', '... got Foo where we expected');
}

foreach my $uri (qw(
        /foo/bar
        /foo/bar?say=hello
        /foo/bar/bling/bar
        /foo/bar/?bar=baz    
        /foo/bar/bazz        
    )) {
    is($server->is_valid_entry_point($uri), 'Foo::Bar', '... got Foo::Bar where we expected');
}

foreach my $uri (qw(
        /foo/bar/baz
        /foo/bar/baz?say=hello
        /foo/bar/baz/bling/bar
        /foo/bar/baz/?bar=baz 
        /foo/bar/baz/../
    )) {
    is($server->is_valid_entry_point($uri), 'Foo::Bar::Baz', '... got Foo::Bar::Baz where we expected');
}

foreach my $uri (qw(
        /fooo
        /food?say=hello
        /fooo/bar
        /fooo/barr/baz
    )) {
    is($server->is_valid_entry_point($uri), undef, '... got undef where we expected');
}