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