]> git.donarmstrong.com Git - debbugs.git/blob - t/08_pkgreport.t
pkgreport does not require common.pl; remove cd
[debbugs.git] / t / 08_pkgreport.t
1 # -*- mode: cperl;-*-
2
3
4 use Test::More tests => 3;
5
6 use warnings;
7 use strict;
8
9 # Here, we're going to shoot messages through a set of things that can
10 # happen.
11
12 # First, we're going to send mesages to receive.
13 # To do so, we'll first send a message to submit,
14 # then send messages to the newly created bugnumber.
15
16 use IO::File;
17 use File::Temp qw(tempdir);
18 use Cwd qw(getcwd);
19 use Debbugs::MIME qw(create_mime_message);
20 use File::Basename qw(dirname basename);
21 use Test::WWW::Mechanize;
22 # The test functions are placed here to make things easier
23 use lib qw(t/lib);
24 use DebbugsTest qw(:all);
25
26 my %config = create_debbugs_configuration();
27
28
29 # create a bug
30 send_message(to=>'submit@bugs.something',
31              headers => [To   => 'submit@bugs.something',
32                          From => 'foo@bugs.something',
33                          Subject => 'Submitting a bug',
34                         ],
35              body => <<EOF) or fail('Unable to send message');
36 Package: foo
37 Severity: normal
38
39 This is a silly bug
40 EOF
41
42
43 # test bugreport.cgi
44
45 # start up an HTTP::Server::Simple
46 my $pkgreport_cgi_handler = sub {
47      # I do not understand why this is necessary.
48      $ENV{DEBBUGS_CONFIG_FILE} = "$config{config_dir}/debbugs_config";
49      my $content = qx(perl -I. -T cgi/pkgreport.cgi);
50      # Strip off the Content-Type: stuff
51      $content =~ s/^\s*Content-Type:[^\n]+\n*//si;
52      print $content;
53 };
54
55 my $port = 11342;
56
57 ok(DebbugsTest::HTTPServer::fork_and_create_webserver($pkgreport_cgi_handler,$port),
58    'forked HTTP::Server::Simple successfully');
59
60
61 my $mech = Test::WWW::Mechanize->new(autocheck => 1);
62
63 $mech->get_ok('http://localhost:'.$port.'/?pkg=foo');
64
65 # I'd like to use $mech->title_ok(), but I'm not sure why it doesn't
66 # work.
67 ok($mech->content()=~ qr/package foo/i,
68    'Package title seems ok',
69   );
70
71 # Test more stuff here