]> git.donarmstrong.com Git - debbugs.git/blob - t/15_rebuild_indexdb.t
create_config now calls BAIL_OUT on its own
[debbugs.git] / t / 15_rebuild_indexdb.t
1 # -*- mode: cperl;-*-
2
3 use Test::More tests => 9;
4
5 use warnings;
6 use strict;
7
8 use utf8;
9
10 # Here, we're going to shoot messages through a set of things that can
11 # happen.
12
13 # First, we're going to send mesages to receive.
14 # To do so, we'll first send a message to submit,
15 # then send messages to the newly created bugnumber.
16
17 use IO::File;
18 use File::Temp qw(tempdir);
19 use Cwd qw(getcwd);
20 use Debbugs::MIME qw(create_mime_message);
21 use File::Basename qw(dirname basename);
22 # The test functions are placed here to make things easier
23 use lib qw(t/lib);
24 use DebbugsTest qw(:all);
25 use Data::Dumper;
26 use Encode qw(decode encode decode_utf8 encode_utf8);
27
28 # HTTP::Server:::Simple defines a SIG{CHLD} handler that breaks system; undef it here.
29 $SIG{CHLD} = sub {};
30 my %config = create_debbugs_configuration();
31
32
33 my $sendmail_dir = $config{sendmail_dir};
34 my $spool_dir = $config{spool_dir};
35 my $config_dir = $config{config_dir};
36
37
38
39 # We're going to use create mime message to create these messages, and
40 # then just send them to receive.
41
42 send_message(to=>'submit@bugs.something',
43              headers => [To   => 'submit@bugs.something',
44                          From => 'föoff@bugs.something',
45                          Subject => 'Submiting a bug',
46                         ],
47              body => <<EOF,attachments => [{Type=>"text/plain",Charset=>"utf-8",Data=>encode_utf8(<<EOF2)}]) or fail('Unable to send message');
48 Package: foo
49 Severity: normal
50
51 This is a silly bug
52 EOF
53 This is the silly bug's test ütff8 attachment.
54 EOF2
55
56
57
58 # now we check to see that we have a bug, and nextnumber has been incremented
59 ok(-e "$spool_dir/db-h/01/1.log",'log file created');
60 ok(-e "$spool_dir/db-h/01/1.summary",'sumary file created');
61 ok(-e "$spool_dir/db-h/01/1.status",'status file created');
62 ok(-e "$spool_dir/db-h/01/1.report",'report file created');
63 ok(system('sh','-c','[ $(grep "attachment." '.$spool_dir.'/db-h/01/1.log|grep -v "ütff8"|wc -l) -eq 0 ]') == 0,
64    'Everything attachment is escaped properly');
65
66 # next, we check to see that (at least) the proper messages have been
67 # sent out. 1) ack to submitter 2) mail to maintainer
68
69 # This keeps track of the previous size of the sendmail directory
70 my $SD_SIZE = 0;
71 $SD_SIZE =
72     num_messages_sent($SD_SIZE,2,
73                       $sendmail_dir,
74                       'submit messages appear to have been sent out properly',
75                      );
76
77
78 # now send a message to the bug
79
80 send_message(to => '1@bugs.something',
81              headers => [To   => '1@bugs.something',
82                          From => 'föoff@bugs.something',
83                          Subject => 'Sending a message to a bug',
84                         ],
85              body => <<EOF) or fail('sending message to 1@bugs.someting failed');
86 Package: foo
87 Severity: normal
88
89 This is a silly bug
90 EOF
91
92 $SD_SIZE =
93     num_messages_sent($SD_SIZE,2,
94                       $sendmail_dir,
95                       '1@bugs.something messages appear to have been sent out properly');
96
97 # just check to see that control doesn't explode
98 send_message(to => 'control@bugs.something',
99              headers => [To   => 'control@bugs.something',
100                          From => 'föoff@bugs.something',
101                          Subject => 'Munging a bug',
102                         ],
103              body => <<EOF) or fail 'message to control@bugs.something failed';
104 severity 1 wishlist
105 retitle 1 ütff8 title encoding test
106 thanks
107 EOF
108
109 $SD_SIZE =
110    num_messages_sent($SD_SIZE,1,
111                      $sendmail_dir,
112                      'control@bugs.something messages appear to have been sent out properly');
113 # now we need to check to make sure the control message was processed without errors
114 # now we need to check to make sure that the control message actually did anything
115 # This is an eval because $ENV{DEBBUGS_CONFIG_FILE} isn't set at BEGIN{} time
116 eval "use Debbugs::Status qw(read_bug writebug);";
117 ok(system('bin/debbugs-rebuild-index.db')==0,'debbugs-rebuild-index seems to work');