Skip to content

Commit

Permalink
Revert improved test added in b6b8f72, replace with original from dab…
Browse files Browse the repository at this point in the history
…e173

The new test contains a case which it *seems* to me needs to be an exception.
Since we are already pretty late with 28, I am just reverting the test alone
(while keeping the changes). This way I am not backing myself into a corner
with a published test in 29.
  • Loading branch information
ribasushi committed Jul 29, 2014
1 parent ba7892a commit 1016d16
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions t/prefetch/empty_cache.t
Expand Up @@ -8,32 +8,32 @@ use DBICTest;

my $schema = DBICTest->init_schema();

my $no_albums_artist = { name => 'We Have No Albums' };
$schema->resultset('Artist')->create($no_albums_artist);

foreach (
[empty => \'0 = 1', 0],
[nonempty => $no_albums_artist, 1],
) {
my ($desc, $cond, $count) = @$_;

my $artists_rs = $schema->resultset('Artist')
->search($cond, { prefetch => 'cds', cache => 1 });

$schema->is_executed_querycount( sub {
my @artists = $artists_rs->all;
is( 0+@{$artists_rs->get_cache}, $count, "$desc cache on original resultset" );
is( 0+@artists, $count, "$desc original resultset" );
}, 1, "->all on $desc original resultset hit db" );

$schema->is_executed_querycount( sub {
my $cds_rs = $artists_rs->related_resultset('cds');
is_deeply( $cds_rs->get_cache, [], 'empty cache on related resultset' );

my @cds = $cds_rs->all;
is( 0+@cds, 0, 'empty related resultset' );
}, 0, '->all on empty related resultest didn\'t hit db' );
}
my $queries;
my $debugcb = sub { $queries++; };
my $orig_debug = $schema->storage->debug;

{
$queries = 0;
$schema->storage->debugcb($debugcb);
$schema->storage->debug(1);

my $cds_rs = $schema->resultset('CD')
->search(\'0 = 1', { prefetch => 'tracks', cache => 1 });

my @cds = $cds_rs->all;
is( $queries, 1, '->all on empty original resultset hit db' );
is_deeply( $cds_rs->get_cache, [], 'empty cache on original resultset' );
is( 0+@cds, 0, 'empty original resultset' );

my $tracks_rs = $cds_rs->related_resultset('tracks');
is_deeply( $tracks_rs->get_cache, [], 'empty cache on related resultset' );

my @tracks = $tracks_rs->all;
is( $queries, 1, "->all on empty related resultset didn't hit db" );
is( 0+@tracks, 0, 'empty related resultset' );

$schema->storage->debugcb(undef);
$schema->storage->debug($orig_debug);
}

done_testing;

0 comments on commit 1016d16

Please sign in to comment.