File: reload.t

package info (click to toggle)
libapache2-reload-perl 0.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 176 kB
  • sloc: perl: 339; makefile: 19; sh: 5
file content (70 lines) | stat: -rw-r--r-- 1,497 bytes parent folder | download | duplicates (16)
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
use strict;
use warnings FATAL => 'all';

use Apache::Test;
use Apache::TestUtil;
use Apache::TestRequest;
use File::Spec::Functions qw(catfile tmpdir);

Apache::TestRequest::user_agent(keep_alive => 1);

plan tests => 3, need 'HTML::HeadParser';

my $test_file = catfile qw(Reload Test.pm);

my $location = '/reload';

my @tests = qw(const prototype simple subpackage);

my $header = join '', <DATA>;

my $initial = <<'EOF';
sub simple { 'simple' }
use constant const => 'const';
sub prototype($) { 'prototype' }
sub promised;
EOF

my $modified = <<'EOF';
sub simple { 'SIMPLE' }
use constant const => 'CONST';
sub prototype($$) { 'PROTOTYPE' }
EOF

t_write_test_lib($test_file, $header, $initial);

{
    my $expected = join '', map { "$_:$_\n" } sort @tests;
    my $received = GET $location;
    ok t_cmp($received->content, $expected, 'Initial');
}

t_write_test_lib($test_file, $header, $modified);

{
    my $expected = join '', map { "$_:" . uc($_) . "\n" } sort @tests;
    my $received = GET $location;
    ok t_cmp($received->content, $expected, 'Reload');
}

{
    my $expected = "unregistered OK";
    my $received = GET "$location?last";
    ok t_cmp($received->content, $expected, 'Unregister');
}

__DATA__
package Reload::Test;

our @methods = qw(const prototype simple subpackage);

sub subpackage { return Reload::Test::SubPackage::subpackage() }

sub run {
    my $r = shift;
    foreach my $m (sort @methods) {
        $r->print($m, ':', __PACKAGE__->$m(), "\n");
    }
}

1;