Commit | Line | Data |
4ffbc1d6 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
7 | |
8 | plan tests => 2; |
9 | |
10 | # Set up the "usual" sqlite for DBICTest |
11 | my $schema = DBICTest->init_schema; |
12 | |
13 | # Make sure we're connected by doing something |
14 | my @art = $schema->resultset("Artist")->search({ }, { order_by => 'name DESC'}); |
15 | cmp_ok(@art, '==', 3, "Three artists returned"); |
16 | |
17 | # Disconnect the dbh, and be sneaky about it |
18 | $schema->storage->_dbh->disconnect; |
19 | |
20 | # Try the operation again - What should happen here is: |
21 | # 1. S::DBI blindly attempts the SELECT, which throws an exception |
22 | # 2. It catches the exception, checks ->{Active}/->ping, sees the disconnected state... |
23 | # 3. Reconnects, and retries the operation |
24 | # 4. Success! |
25 | my @art_two = $schema->resultset("Artist")->search({ }, { order_by => 'name DESC'}); |
26 | cmp_ok(@art_two, '==', 3, "Three artists returned"); |