]> git.donarmstrong.com Git - debbugs.git/blob - t/07_control_limit.t
Plural/singular agreement in error message
[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;
28 eval {
29      %config = create_debbugs_configuration(debug => exists $ENV{DEBUG}?$ENV{DEBUG}:0);
30 };
31 if ($@) {
32      BAIL_OUT($@);
33 }
34
35 my $sendmail_dir = $config{sendmail_dir};
36 my $spool_dir = $config{spool_dir};
37 my $config_dir = $config{config_dir};
38
39 END{
40      if ($ENV{DEBUG}) {
41           diag("spool_dir:   $spool_dir\n");
42           diag("config_dir:   $config_dir\n");
43           diag("sendmail_dir: $sendmail_dir\n");
44      }
45 }
46
47 # We're going to use create mime message to create these messages, and
48 # then just send them to receive.
49
50 send_message(to=>'submit@bugs.something',
51              headers => [To   => 'submit@bugs.something',
52                          From => 'foo@bugs.something',
53                          Subject => 'Submiting a bug',
54                         ],
55              body => <<EOF) or fail('Unable to send message');
56 Package: foo
57 Severity: normal
58
59 This is a silly bug
60 EOF
61
62 my $SD_SIZE = dirsize($sendmail_dir);
63 send_message(to => 'control@bugs.something',
64              headers => [To   => 'control@bugs.something',
65                          From => 'foo@bugs.something',
66                          Subject => "Munging a bug with limit_package_bar",
67                         ],
68              body => <<EOF) or fail 'message to control@bugs.something failed';
69 debug 10
70 limit package bar
71 severity 1 wishlist
72 thanks
73 EOF
74
75 $SD_SIZE =
76     num_messages_sent($SD_SIZE,1,
77                            $sendmail_dir,
78                       'control@bugs.something messages appear to have been sent out properly');
79
80 # make sure this fails
81 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,
82    'control@bugs.something'. "limit message failed with 1 error");
83
84 send_message(to => 'control@bugs.something',
85              headers => [To   => 'control@bugs.something',
86                          From => 'foo@bugs.something',
87                          Subject => "Munging a bug with limit_package_foo",
88                         ],
89              body => <<EOF) or fail 'message to control@bugs.something failed';
90 debug 10
91 limit package foo
92 severity 1 wishlist
93 thanks
94 EOF
95
96 $SD_SIZE =
97     num_messages_sent($SD_SIZE,1,
98                            $sendmail_dir,
99                       'control@bugs.something messages appear to have been sent out properly');
100
101 # make sure this fails
102 ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Munging a bug with limit_package_foo")) == 0,
103    'control@bugs.something'. "limit message succeeded with no errors");
104
105 send_message(to=>'submit@bugs.something',
106              headers => [To   => 'submit@bugs.something',
107                          From => 'foo@bugs.something',
108                          Subject => 'Submiting a bug',
109                         ],
110              body => <<EOF) or fail('Unable to send message');
111 Package: foo, bar
112 Severity: normal
113
114 This is a silly bug
115 EOF
116 $SD_SIZE = dirsize($sendmail_dir);
117
118
119 send_message(to => 'control@bugs.something',
120              headers => [To   => 'control@bugs.something',
121                          From => 'foo@bugs.something',
122                          Subject => "Munging a bug with limit_package_bar",
123                         ],
124              body => <<EOF) or fail 'message to control@bugs.something failed';
125 debug 10
126 limit package baz
127 severity 2 wishlist
128 thanks
129 EOF
130
131 $SD_SIZE =
132     num_messages_sent($SD_SIZE,1,
133                            $sendmail_dir,
134                       'control@bugs.something messages appear to have been sent out properly');
135
136 # make sure this fails
137 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,
138    'control@bugs.something'. "limit message failed with 1 error");
139
140 send_message(to => 'control@bugs.something',
141              headers => [To   => 'control@bugs.something',
142                          From => 'foo@bugs.something',
143                          Subject => "Munging a bug with limit_package_foo",
144                         ],
145              body => <<EOF) or fail 'message to control@bugs.something failed';
146 debug 10
147 limit package foo
148 severity 2 wishlist
149 thanks
150 EOF
151
152 $SD_SIZE =
153     num_messages_sent($SD_SIZE,1,
154                            $sendmail_dir,
155                       'control@bugs.something messages appear to have been sent out properly');
156
157 # make sure this fails
158 ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Munging a bug with limit_package_foo")) == 0,
159    'control@bugs.something'. "limit message succeeded with no errors");