9ce05b4da1eb0c169d9314665417a422fe9f4e86
[dbsrgits/DBIx-Class.git] / t / storage / exception.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7 use Test::Exception;
8 use lib qw(t/lib);
9 use DBICTest;
10 use DBICTest::Schema;
11
12 # make sure nothing eats the exceptions (an unchecked eval in Storage::DESTROY used to be a problem)
13
14 {
15   package Dying::Storage;
16
17   use warnings;
18   use strict;
19
20   use base 'DBIx::Class::Storage::DBI';
21
22   sub _populate_dbh {
23     my $self = shift;
24     my $death = $self->_dbi_connect_info->[3]{die};
25
26     die "storage test died: $death" if $death eq 'before_populate';
27     my $ret = $self->next::method (@_);
28     die "storage test died: $death" if $death eq 'after_populate';
29
30     return $ret;
31   }
32 }
33
34 for (qw/before_populate after_populate/) {
35   dies_ok (sub {
36     my $schema = DBICTest::Schema->clone;
37     $schema->storage_type ('Dying::Storage');
38     $schema->connection (DBICTest->_database, { die => $_ });
39     $schema->storage->ensure_connected;
40   }, "$_ exception found");
41 }
42
43 done_testing;