X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F84serialize.t;h=021c44e70198b6abe1fb744d7681c645833846d8;hb=9d0785d5dc8143fc41584fed2f8f9da7811e31c1;hp=ffe03687f519dfb534ad7d2e0c11ce811b7ec735;hpb=0e08abb27b072e1e0f38d5639442a9275781c6e7;p=dbsrgits%2FDBIx-Class.git diff --git a/t/84serialize.t b/t/84serialize.t index ffe0368..021c44e 100644 --- a/t/84serialize.t +++ b/t/84serialize.t @@ -1,9 +1,11 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + use strict; use warnings; use Test::More; use Test::Exception; -use lib qw(t/lib); + use DBICTest; use Storable qw(dclone freeze nfreeze thaw); use Scalar::Util qw/refaddr/; @@ -58,8 +60,10 @@ my %stores = ( ); -if ($ENV{DBICTEST_MEMCACHED}) { - if (DBIx::Class::Optional::Dependencies->req_ok_for ('test_memcached')) { +SKIP: { + require DBIx::Class::Optional::Dependencies; + DBIx::Class::Optional::Dependencies->skip_without('test_memcached'); + my $memcached = Cache::Memcached->new( { servers => [ $ENV{DBICTEST_MEMCACHED} ] } ); @@ -72,21 +76,8 @@ if ($ENV{DBICTEST_MEMCACHED}) { local $DBIx::Class::ResultSourceHandle::thaw_schema = $schema; return $memcached->get($key); }; - } - else { - SKIP: { - skip 'Memcached tests need ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_memcached'), 1; - } - } -} -else { - SKIP: { - skip 'Set $ENV{DBICTEST_MEMCACHED} to run the memcached serialization tests', 1; - } } - - for my $name (keys %stores) { my $store = $stores{$name}; @@ -138,17 +129,12 @@ for my $name (keys %stores) { # Test resultsource with cached rows - my $query_count; - $cd_rs = $cd_rs->search ({}, { cache => 1 }); - - my $orig_debug = $schema->storage->debug; - $schema->storage->debug(1); - $schema->storage->debugcb(sub { $query_count++ } ); + $schema->is_executed_querycount( sub { + $cd_rs = $cd_rs->search ({}, { cache => 1 }); - # this will hit the database once and prime the cache - my @cds = $cd_rs->all; + # this will hit the database once and prime the cache + my @cds = $cd_rs->all; - lives_ok { $copy = $store->($cd_rs); ref_ne($copy, $cd_rs, 'Cached resultset cloned'); is_deeply ( @@ -158,12 +144,7 @@ for my $name (keys %stores) { ); is ($copy->count, $cd_rs->count, 'Cached count identical'); - } "serialize cached resultset lives: $name"; - - is ($query_count, 1, 'Only one db query fired'); - - $schema->storage->debug($orig_debug); - $schema->storage->debugcb(undef); + }, 1, 'Only one db query fired'); } # test schema-less detached thaw