A more straightforward txn_begin fix, some more test fixes
[dbsrgits/DBIx-Class.git] / t / 92storage_ping_count.t
CommitLineData
25546937 1use strict;
2use warnings;
3
25546937 4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7use Data::Dumper;
8use DBIC::SqlMakerTest;
9
10my $ping_count = 0;
11
12{
13 local $SIG{__WARN__} = sub {};
14 require DBIx::Class::Storage::DBI;
15
16 my $ping = \&DBIx::Class::Storage::DBI::_ping;
17
18 *DBIx::Class::Storage::DBI::_ping = sub {
19 $ping_count++;
20 goto &$ping;
21 };
22}
23
d68d84f8 24
25# We do not count pings during deploy() because of the flux
26# around sqlt. Eventually there should be no pings at all
27my $schema = DBICTest->init_schema( sqlite_use_file => 1, no_populate => 1 );
28
29TODO: {
30 local $TODO = 'Unable to fix before proper deploy() error handling';
31 is ($ping_count, 0, 'no _ping() calls during deploy');
32 $ping_count = 0;
33}
34
35DBICTest->populate_schema ($schema);
36
28be49a6 37# perform some operations and make sure they don't ping
25546937 38
28be49a6 39$schema->resultset('CD')->create({
40 cdid => 6, artist => 3, title => 'mtfnpy', year => 2009
41});
25546937 42
28be49a6 43$schema->resultset('CD')->create({
44 cdid => 7, artist => 3, title => 'mtfnpy2', year => 2009
45});
25546937 46
28be49a6 47$schema->storage->_dbh->disconnect;
25546937 48
28be49a6 49$schema->resultset('CD')->create({
50 cdid => 8, artist => 3, title => 'mtfnpy3', year => 2009
51});
25546937 52
28be49a6 53$schema->storage->_dbh->disconnect;
25546937 54
28be49a6 55$schema->txn_do(sub {
56 $schema->resultset('CD')->create({
57 cdid => 9, artist => 3, title => 'mtfnpy4', year => 2009
58 });
59});
25546937 60
61is $ping_count, 0, 'no _ping() calls';
d68d84f8 62
63done_testing;