]> git.donarmstrong.com Git - debbugs.git/blobdiff - t/13_utf8_mail.t
abstract out create config in tests
[debbugs.git] / t / 13_utf8_mail.t
index 8ada76ab01b05a225987cd86c7e8947e357b23ab..8fb49e414b4416659683477e4108f0272e486002 100644 (file)
@@ -1,11 +1,13 @@
 # -*- mode: cperl;-*-
 # $Id: 05_mail.t,v 1.1 2005/08/17 21:46:17 don Exp $
 
-use Test::More tests => 12;
+use Test::More tests => 13;
 
 use warnings;
 use strict;
 
+use utf8;
+
 # Here, we're going to shoot messages through a set of things that can
 # happen.
 
@@ -22,13 +24,13 @@ use File::Basename qw(dirname basename);
 use lib qw(t/lib);
 use DebbugsTest qw(:all);
 use Data::Dumper;
-use Encode qw(decode encode decode_utf8);
+use Encode qw(decode encode decode_utf8 encode_utf8);
 
 # HTTP::Server:::Simple defines a SIG{CHLD} handler that breaks system; undef it here.
 $SIG{CHLD} = sub {};
 my %config;
 eval {
-     %config = create_debbugs_configuration(debug => exists $ENV{DEBUG}?$ENV{DEBUG}:0);
+     %config = create_debbugs_configuration();
 };
 if ($@) {
      BAIL_OUT($@);
@@ -38,23 +40,17 @@ my $sendmail_dir = $config{sendmail_dir};
 my $spool_dir = $config{spool_dir};
 my $config_dir = $config{config_dir};
 
-END{
-     if ($ENV{DEBUG}) {
-         diag("spool_dir:   $spool_dir\n");
-         diag("config_dir:   $config_dir\n");
-         diag("sendmail_dir: $sendmail_dir\n");
-     }
-}
+
 
 # We're going to use create mime message to create these messages, and
 # then just send them to receive.
 
 send_message(to=>'submit@bugs.something',
             headers => [To   => 'submit@bugs.something',
-                        From => 'foo@bugs.something',
+                        From => 'föoff@bugs.something',
                         Subject => 'Submiting a bug',
                        ],
-            body => <<EOF,attachments => [{Type=>"text/plain",Charset=>"utf-8",Data=><<EOF2}]) or fail('Unable to send message');
+            body => <<EOF,attachments => [{Type=>"text/plain",Charset=>"utf-8",Data=>encode_utf8(<<EOF2)}]) or fail('Unable to send message');
 Package: foo
 Severity: normal
 
@@ -89,7 +85,7 @@ $SD_SIZE =
 
 send_message(to => '1@bugs.something',
             headers => [To   => '1@bugs.something',
-                        From => 'foo@bugs.something',
+                        From => 'föoff@bugs.something',
                         Subject => 'Sending a message to a bug',
                        ],
             body => <<EOF) or fail('sending message to 1@bugs.someting failed');
@@ -107,7 +103,7 @@ $SD_SIZE =
 # just check to see that control doesn't explode
 send_message(to => 'control@bugs.something',
             headers => [To   => 'control@bugs.something',
-                        From => 'foo@bugs.something',
+                        From => 'föoff@bugs.something',
                         Subject => 'Munging a bug',
                        ],
             body => <<EOF) or fail 'message to control@bugs.something failed';
@@ -127,8 +123,9 @@ ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: P
 # This is an eval because $ENV{DEBBUGS_CONFIG_FILE} isn't set at BEGIN{} time
 eval "use Debbugs::Status qw(read_bug writebug);";
 my $status = read_bug(bug=>1);
-ok($status->{subject} eq decode_utf8('ütff8 title encoding test'),'bug 1 retitled');
+ok($status->{subject} eq 'ütff8 title encoding test','bug 1 retitled');
 ok($status->{severity} eq 'wishlist','bug 1 wishlisted');
 ok(system('sh','-c','[ $(egrep "retitle.*encoding test" '.$spool_dir.'/db-h/01/1.log|grep -v "=C3=BCt=EF=AC=808"|wc -l) -eq 0 ]') == 0,
    'Control messages escaped properly');
-
+ok(system('sh','-c',encode_utf8('grep -q "föoff@bugs.something" '.$spool_dir.'/index.db'))==0,
+   'index.db not double escaped');