]> git.donarmstrong.com Git - debbugs.git/blobdiff - t/07_bugreport.t
Fix mbox output of bugreports to properly use filehandle
[debbugs.git] / t / 07_bugreport.t
index ea33725e6d6967351b0d91ee2339aae6c5daf643..0366be41b9c5b72a5229c94f0aafe4a0bb01480e 100644 (file)
@@ -1,7 +1,7 @@
 # -*- mode: cperl;-*-
-# $Id: 05_mail.t,v 1.1 2005/08/17 21:46:17 don Exp $
 
-use Test::More tests => 2;
+
+use Test::More tests => 6;
 
 use warnings;
 use strict;
@@ -22,7 +22,6 @@ use Test::WWW::Mechanize;
 # The test functions are placed here to make things easier
 use lib qw(t/lib);
 use DebbugsTest qw(:all);
-use Data::Dumper;
 
 my %config;
 eval {
@@ -45,7 +44,7 @@ END{
 send_message(to=>'submit@bugs.something',
             headers => [To   => 'submit@bugs.something',
                         From => 'foo@bugs.something',
-                        Subject => 'Submiting a bug',
+                        Subject => 'Submitting a bug',
                        ],
             body => <<EOF) or fail('Unable to send message');
 Package: foo
@@ -61,7 +60,9 @@ EOF
 my $bugreport_cgi_handler = sub {
      # I do not understand why this is necessary.
      $ENV{DEBBUGS_CONFIG_FILE} = "$config{config_dir}/debbugs_config";
-     print qx(perl -I. -T cgi/bugreport.cgi);
+     my $content = qx(perl -I. -T cgi/bugreport.cgi);
+     $content =~ s/^\s*Content-Type:[^\n]+\n*//si;
+     print $content;
 };
 
 my $port = 11342;
@@ -69,7 +70,20 @@ my $port = 11342;
 ok(DebbugsTest::HTTPServer::fork_and_create_webserver($bugreport_cgi_handler,$port),
    'forked HTTP::Server::Simple successfully');
 
-
 my $mech = Test::WWW::Mechanize->new();
 
-$mech->get_ok('http://localhost:'.$port.'/?bug=1');
+$mech->get_ok('http://localhost:'.$port.'/?bug=1',
+             'Page received ok');
+ok($mech->content() =~ qr/\<title\>\#1.+Submitting a bug/i,
+   'Title of bug is submitting a bug');
+
+$mech->get_ok('http://localhost:'.$port.'/?bug=1;mbox=yes',
+              'Page received ok');
+ok($mech->content() =~ qr/Subject: Submitting a bug/i,
+   'Subject of bug maibox is right');
+ok($mech->content() =~ qr/^From /m,
+   'Starts with a From appropriately');
+
+
+# Other tests for bugs in the page should be added here eventually
+