typo pointed out by kangas
[dbsrgits/DBIx-Class.git] / t / 33storage_reconnect.t
CommitLineData
4ffbc1d6 1use strict;
2use warnings;
3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7
8plan tests => 2;
9
10# Set up the "usual" sqlite for DBICTest
11my $schema = DBICTest->init_schema;
12
13# Make sure we're connected by doing something
14my @art = $schema->resultset("Artist")->search({ }, { order_by => 'name DESC'});
15cmp_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!
25my @art_two = $schema->resultset("Artist")->search({ }, { order_by => 'name DESC'});
26cmp_ok(@art_two, '==', 3, "Three artists returned");