]> git.donarmstrong.com Git - debbugs.git/blob - t/21_database.t
add start of database seting
[debbugs.git] / t / 21_database.t
1 # -*- mode: cperl;-*-
2
3 use Test::More;
4
5 use warnings;
6 use strict;
7
8 # Here, we're going to shoot messages through a set of things that can
9 # happen.
10
11 # First, we're going to send mesages to receive.
12 # To do so, we'll first send a message to submit,
13 # then send messages to the newly created bugnumber.
14
15 use IO::File;
16 use File::Temp qw(tempdir);
17 use Cwd qw(getcwd);
18 use Debbugs::MIME qw(create_mime_message);
19 use File::Basename qw(dirname basename);
20 use Test::WWW::Mechanize;
21 use HTTP::Status qw(RC_NOT_MODIFIED);
22 # The test functions are placed here to make things easier
23 use lib qw(t/lib);
24 use DebbugsTest qw(:all);
25
26 our $tests_run = 0;
27
28 my %config = create_debbugs_configuration();
29
30
31 # create a bug
32 send_message(to=>'submit@bugs.something',
33              headers => [To   => 'submit@bugs.something',
34                          From => 'foo@bugs.something',
35                          Subject => 'Submitting a bug',
36                         ],
37              body => <<EOF) or fail('Unable to send message');
38 Package: foo
39 Severity: normal
40
41 This is a silly bug
42 EOF
43
44 my $pgsql = create_postgresql_database();
45 update_postgresql_database($pgsql);
46
47 BEGIN{
48     use_ok('Debbugs::DB')
49 }
50 $tests_run++;
51
52 my $s;
53
54 ok($s = Debbugs::DB->connect($pgsql->dsn),
55    "Able to connect to database");
56 $tests_run++;
57
58 ok($s->resultset('Bug')->search({id => 1})->single->subject eq
59    'Submitting a bug',
60    "Correct bug title");
61 $tests_run++;
62
63 done_testing($tests_run);