File: 30-driver_errors.t

package info (click to toggle)
libcgi-application-plugin-anytemplate-perl 0.18-1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 776 kB
  • ctags: 120
  • sloc: perl: 1,073; sh: 8; makefile: 2
file content (58 lines) | stat: -rwxr-xr-x 1,591 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
use strict;
use Test::More 'no_plan';

{
    package WebApp;
    use CGI::Application;
    use vars '@ISA';
    @ISA = ('CGI::Application');
    use Test::More;
    use CGI::Application::Plugin::AnyTemplate;
    use lib 't/tlib';

    sub setup {
        my $self = shift;
        $self->header_type('none');
        $self->start_mode('simple');
        $self->run_modes([qw/simple/]);

        $self->template('non_existent')->config(
            default_type  => '___NON_EXISTENT__',
        );
        $self->template('poorly_implemented1')->config(
            default_type  => 'MyCAPATDriver1',
        );
        $self->template('poorly_implemented2')->config(
            default_type  => 'MyCAPATDriver2',
        );
        $self->template('poorly_implemented3')->config(
            default_type  => 'MyCAPATDriver3',
        );
        $self->template('poorly_implemented4')->config(
            default_type  => 'MyCAPATDriver4',
        );
    }

    sub simple {
        my $self = shift;

        my $template;
        eval {
            $template = $self->template('non_existent')->load;
        };
        ok($@, 'non existent driver');
        eval {
            $template = $self->template('poorly_implemented1')->load;
        };
        ok($@, 'poorly implemented driver: missing init');

        $template = $self->template('poorly_implemented2')->load;
        eval {
            $template->output;
        };
        like($@, qr/render_template.*virtual/, 'poorly implemented driver - does not provide render_template method');
        '';
    }
}

WebApp->new->run;