]> git.donarmstrong.com Git - debbugs.git/blob - t/20_multipart_mime_pseudoheaders.t
assume unknown encodings are UTF-8
[debbugs.git] / t / 20_multipart_mime_pseudoheaders.t
1 # -*- mode: cperl;-*-
2
3 use Test::More;
4
5 use warnings;
6 use strict;
7 use utf8;
8
9 # The test functions are placed here to make things easier
10 use lib qw(t/lib);
11 use DebbugsTest qw(:all);
12 use Data::Dumper;
13
14 my %config =
15     create_debbugs_configuration();
16
17 my $sendmail_dir = $config{sendmail_dir};
18 my $spool_dir = $config{spool_dir};
19
20 # We're going to use create mime message to create these messages, and
21 # then just send them to receive.
22
23 send_message(to=>'submit@bugs.something',
24              headers => [To   => 'submit@bugs.something',
25                          From => 'foo@bugs.something',
26                          Subject => 'Submiting a bug',
27                         ],
28              body => <<EOF,
29 Package: foo
30 Severity: normal
31
32 This is a silly bug
33 EOF
34              attachments => [<<EOF]) or fail('Unable to send message');
35 This is a silly attachment to make sure that pseudoheaders work
36 EOF
37 # now we check to see that we have a bug, and nextnumber has been incremented
38 ok(-e "$spool_dir/db-h/01/1.log",'log file created');
39 ok(-e "$spool_dir/db-h/01/1.summary",'sumary file created');
40 ok(-e "$spool_dir/db-h/01/1.status",'status file created');
41 ok(-e "$spool_dir/db-h/01/1.report",'report file created');
42
43 # next, we check to see that (at least) the proper messages have been
44 # sent out. 1) ack to submitter 2) mail to maintainer
45
46 # This keeps track of the previous size of the sendmail directory
47 my $SD_SIZE = 0;
48 $SD_SIZE =
49     num_messages_sent($SD_SIZE,2,
50                       $sendmail_dir,
51                       'submit messages appear to have been sent out properly',
52                      );
53
54 send_message(to=>'1-done@bugs.something',
55              headers => [To   => '1-done@bugs.something',
56                          From => 'foo@bugs.something',
57                          Subject => 'Closing a bug with pseudoheaders',
58                         ],
59              body => <<EOF,
60 Source: foo
61 Version: 1
62
63
64 I've closed this silly bug; using an UTF-8 non-breaking space to test that
65 https://bugs.debian.org/817128 was fixed too.
66 EOF
67              attachments => [<<EOF,
68 This is one silly attachment to make sure that pseudoheaders work
69 EOF
70                              <<EOF]) or fail('Unable to send message');
71 And this is another, just in case.
72 EOF
73
74 # now we need to check to make sure that the control message actually did anything
75 # This is an eval because $ENV{DEBBUGS_CONFIG_FILE} isn't set at BEGIN{} time
76 eval "use Debbugs::Status qw(read_bug writebug);";
77 my $status = read_bug(bug=>1);
78 is($status->{done},'foo@bugs.something','bug 1 was closed properly');
79 is_deeply($status->{fixed_versions},["1"],'bug 1 was fixed in the proper version');
80
81 done_testing();