File: 02-mailer.t

package info (click to toggle)
libsvn-hooks-perl 1.36-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 380 kB
  • sloc: perl: 1,365; makefile: 7
file content (103 lines) | stat: -rwxr-xr-x 1,795 bytes parent folder | download | duplicates (5)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# -*- cperl -*-

use strict;
use warnings;
use lib 't';
use Test::More;

require "test-functions.pl";

my $io_available = 1;

if (not can_svn()) {
    plan skip_all => 'Cannot find or use svn commands.';
}
else {
    plan tests => 10;
}

my $t    = reset_repo();
my $wc   = catdir($t, 'wc');

set_hook(<<'EOS');
use SVN::Hooks::Mailer;
EOS

sub work {
    my $file = catfile($wc, $_[0]);
    <<"EOS";
echo txt >$file
svn add -q --no-auto-props $file
svn ci -mmessage $wc
EOS
}

set_conf(<<'EOS');
EMAIL_CONFIG();
EOS

work_nok('config sans args', 'DEPRECATED', work('f'));

set_conf(<<'EOS');
EMAIL_CONFIG(WHAT => 1);
EOS

work_nok('config invalid', 'DEPRECATED', work('f'));

set_conf(<<'EOS');
EMAIL_COMMIT(1);
EOS

work_nok('commit odd args', 'DEPRECATED', work('f'));

set_conf(<<'EOS');
EMAIL_COMMIT(what => 1);
EOS

work_nok('commit invalid opt', 'DEPRECATED', work('f'));

set_conf(<<'EOS');
EMAIL_COMMIT(match => 1);
EOS

work_nok('commit invalid match', "DEPRECATED", work('f'));

set_conf(<<'EOS');
EMAIL_COMMIT(match => qr/./);
EOS

work_nok('commit missing from', "DEPRECATED", work('f'));

set_conf(<<'EOS');
EMAIL_COMMIT(match => qr/./, from => 's@a.b');
EOS

work_nok('commit missing to', "DEPRECATED", work('f'));

exit 0 unless $io_available;

my $log = '02-mailer.log';

set_conf(<<'EOS');
EMAIL_CONFIG(IO => '02-mailer.log');
EMAIL_COMMIT(
    match => qr/^a/,
    tag   => 'A',
    from  => 'from@example.net',
    to    => 'to@example.net',
    diff  => undef,
);
EMAIL_COMMIT(
    match => qr/^b/,
    tag   => 'B',
    from  => 'from@example.net',
    to    => 'to@example.net',
    diff  => ['--no-diff-deleted'],
);
EOS

work_nok('commit none', 'DEPRECATED', work('none'));

work_nok('commit A', 'DEPRECATED', work('a'));

work_nok('commit B', 'DEPRECATED', work('b'));