X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F92storage_on_connect_do.t;h=62712affbab5c41fd2e3dab42cf254d9af088211;hb=07d404a8b7f0e2f0f23c7de81044bea4689001b8;hp=a7362722177c1601be6d81cc9108dd8f8f8f4b1b;hpb=6d2e7a96f2b9f1e9f5718a421831344dcdb400a3;p=dbsrgits%2FDBIx-Class.git diff --git a/t/92storage_on_connect_do.t b/t/92storage_on_connect_do.t index a736272..62712af 100644 --- a/t/92storage_on_connect_do.t +++ b/t/92storage_on_connect_do.t @@ -14,13 +14,20 @@ my $schema = DBICTest->init_schema( ok $schema->connection( DBICTest->_database, { - on_connect_do => ['CREATE TABLE TEST_empty (id INTEGER)'], + on_connect_do => [ + 'CREATE TABLE TEST_empty (id INTEGER)', + [ 'INSERT INTO TEST_empty VALUES (?)', {}, 2 ], + \&insert_from_subref, + ], on_disconnect_do => [\&check_exists, 'DROP TABLE TEST_empty', \&check_dropped], }, ), 'connection()'; -ok $schema->storage->dbh->do('SELECT 1 FROM TEST_empty'), 'on_connect_do() worked'; +is_deeply + $schema->storage->dbh->selectall_arrayref('SELECT * FROM TEST_empty'), + [ [ 2 ], [ 3 ], [ 7 ] ], + 'on_connect_do() worked'; eval { $schema->storage->dbh->do('SELECT 1 FROM TEST_nonexistent'); }; ok $@, 'Searching for nonexistent table dies'; @@ -44,10 +51,20 @@ ok $disconnected, 'on_disconnect_do() called after disconnect()'; sub check_exists { my $storage = shift; ok $storage->dbh->do('SELECT 1 FROM TEST_empty'), 'Table still exists'; + return; } sub check_dropped { my $storage = shift; eval { $storage->dbh->do('SELECT 1 FROM TEST_empty'); }; ok $@, 'Reading from dropped table fails'; + return; +} + +sub insert_from_subref { + my $storage = shift; + return [ + [ 'INSERT INTO TEST_empty VALUES (?)', {}, 3 ], + 'INSERT INTO TEST_empty VALUES (7)', + ]; }