]> git.donarmstrong.com Git - debbugs.git/blob - t/07_control_limit.t
create_config now calls BAIL_OUT on its own
[debbugs.git] / t / 07_control_limit.t
1 # -*- mode: cperl; -*-
2
3 use Test::More tests => 8;
4
5 use warnings;
6 use strict;
7
8 # Here, we're going to shoot messages through a set of things that can
9 # happen.
10
11 # First, we're going to send mesages to receive.
12 # To do so, we'll first send a message to submit,
13 # then send messages to the newly created bugnumber.
14
15 use IO::File;
16 use File::Temp qw(tempdir);
17 use Cwd qw(getcwd);
18 use Debbugs::MIME qw(create_mime_message);
19 use File::Basename qw(dirname basename);
20 # The test functions are placed here to make things easier
21 use lib qw(t/lib);
22 use DebbugsTest qw(:all);
23 use Data::Dumper;
24
25 # HTTP::Server:::Simple defines a SIG{CHLD} handler that breaks system; undef it here.
26 $SIG{CHLD} = sub {};
27 my %config = create_debbugs_configuration();
28
29
30 my $sendmail_dir = $config{sendmail_dir};
31 my $spool_dir = $config{spool_dir};
32 my $config_dir = $config{config_dir};
33
34
35
36 # We're going to use create mime message to create these messages, and
37 # then just send them to receive.
38
39 send_message(to=>'submit@bugs.something',
40              headers => [To   => 'submit@bugs.something',
41                          From => 'foo@bugs.something',
42                          Subject => 'Submiting a bug',
43                         ],
44              body => <<EOF) or fail('Unable to send message');
45 Package: foo
46 Severity: normal
47
48 This is a silly bug
49 EOF
50
51 my $SD_SIZE = dirsize($sendmail_dir);
52 send_message(to => 'control@bugs.something',
53              headers => [To   => 'control@bugs.something',
54                          From => 'foo@bugs.something',
55                          Subject => "Munging a bug with limit_package_bar",
56                         ],
57              body => <<EOF) or fail 'message to control@bugs.something failed';
58 debug 10
59 limit package bar
60 severity 1 wishlist
61 thanks
62 EOF
63
64 $SD_SIZE =
65     num_messages_sent($SD_SIZE,1,
66                            $sendmail_dir,
67                       'control@bugs.something messages appear to have been sent out properly');
68
69 # make sure this fails
70 ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed (with 1 error): Munging a bug with limit_package_bar")) == 0,
71    'control@bugs.something'. "limit message failed with 1 error");
72
73 send_message(to => 'control@bugs.something',
74              headers => [To   => 'control@bugs.something',
75                          From => 'foo@bugs.something',
76                          Subject => "Munging a bug with limit_package_foo",
77                         ],
78              body => <<EOF) or fail 'message to control@bugs.something failed';
79 debug 10
80 limit package foo
81 severity 1 wishlist
82 thanks
83 EOF
84
85 $SD_SIZE =
86     num_messages_sent($SD_SIZE,1,
87                            $sendmail_dir,
88                       'control@bugs.something messages appear to have been sent out properly');
89
90 # make sure this fails
91 ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Munging a bug with limit_package_foo")) == 0,
92    'control@bugs.something'. "limit message succeeded with no errors");
93
94 send_message(to=>'submit@bugs.something',
95              headers => [To   => 'submit@bugs.something',
96                          From => 'foo@bugs.something',
97                          Subject => 'Submiting a bug',
98                         ],
99              body => <<EOF) or fail('Unable to send message');
100 Package: foo, bar
101 Severity: normal
102
103 This is a silly bug
104 EOF
105 $SD_SIZE = dirsize($sendmail_dir);
106
107
108 send_message(to => 'control@bugs.something',
109              headers => [To   => 'control@bugs.something',
110                          From => 'foo@bugs.something',
111                          Subject => "Munging a bug with limit_package_bar",
112                         ],
113              body => <<EOF) or fail 'message to control@bugs.something failed';
114 debug 10
115 limit package baz
116 severity 2 wishlist
117 thanks
118 EOF
119
120 $SD_SIZE =
121     num_messages_sent($SD_SIZE,1,
122                            $sendmail_dir,
123                       'control@bugs.something messages appear to have been sent out properly');
124
125 # make sure this fails
126 ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed (with 1 error): Munging a bug with limit_package_bar")) == 0,
127    'control@bugs.something'. "limit message failed with 1 error");
128
129 send_message(to => 'control@bugs.something',
130              headers => [To   => 'control@bugs.something',
131                          From => 'foo@bugs.something',
132                          Subject => "Munging a bug with limit_package_foo",
133                         ],
134              body => <<EOF) or fail 'message to control@bugs.something failed';
135 debug 10
136 limit package foo
137 severity 2 wishlist
138 thanks
139 EOF
140
141 $SD_SIZE =
142     num_messages_sent($SD_SIZE,1,
143                            $sendmail_dir,
144                       'control@bugs.something messages appear to have been sent out properly');
145
146 # make sure this fails
147 ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Munging a bug with limit_package_foo")) == 0,
148    'control@bugs.something'. "limit message succeeded with no errors");