[Bast-commits] r6840 - in DBIx-Class/0.08/branches/grouped_prefetch/t: . prefetch relationship

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Mon Jun 29 08:07:10 GMT 2009


Author: ribasushi
Date: 2009-06-29 08:07:09 +0000 (Mon, 29 Jun 2009)
New Revision: 6840

Modified:
   DBIx-Class/0.08/branches/grouped_prefetch/t/31stats.t
   DBIx-Class/0.08/branches/grouped_prefetch/t/83cache.t
   DBIx-Class/0.08/branches/grouped_prefetch/t/86might_have.t
   DBIx-Class/0.08/branches/grouped_prefetch/t/prefetch/grouped.t
   DBIx-Class/0.08/branches/grouped_prefetch/t/prefetch/multiple_hasmany.t
   DBIx-Class/0.08/branches/grouped_prefetch/t/prefetch/standard.t
   DBIx-Class/0.08/branches/grouped_prefetch/t/relationship/core.t
   DBIx-Class/0.08/branches/grouped_prefetch/t/relationship/update_or_create_multi.t
   DBIx-Class/0.08/branches/grouped_prefetch/t/relationship/update_or_create_single.t
Log:
Test cleanups

Modified: DBIx-Class/0.08/branches/grouped_prefetch/t/31stats.t
===================================================================
--- DBIx-Class/0.08/branches/grouped_prefetch/t/31stats.t	2009-06-29 07:50:43 UTC (rev 6839)
+++ DBIx-Class/0.08/branches/grouped_prefetch/t/31stats.t	2009-06-29 08:07:09 UTC (rev 6840)
@@ -4,12 +4,7 @@
 use warnings;
 use Test::More;
 
-BEGIN {
-    eval "use DBD::SQLite";
-    plan $@
-        ? ( skip_all => 'needs DBD::SQLite for testing' )
-        : ( tests => 12 );
-}
+plan tests => 12;
 
 use lib qw(t/lib);
 

Modified: DBIx-Class/0.08/branches/grouped_prefetch/t/83cache.t
===================================================================
--- DBIx-Class/0.08/branches/grouped_prefetch/t/83cache.t	2009-06-29 07:50:43 UTC (rev 6839)
+++ DBIx-Class/0.08/branches/grouped_prefetch/t/83cache.t	2009-06-29 08:07:09 UTC (rev 6840)
@@ -9,9 +9,8 @@
 
 my $queries;
 $schema->storage->debugcb( sub{ $queries++ } );
+my $sdebug = $schema->storage->debug;
 
-eval "use DBD::SQLite";
-plan skip_all => 'needs DBD::SQLite for testing' if $@;
 plan tests => 23;
 
 my $rs = $schema->resultset("Artist")->search(
@@ -53,7 +52,7 @@
 
 is( $queries, 1, 'revisiting a row does not issue a query when cache => 1' );
 
-$schema->storage->debug(0);
+$schema->storage->debug($sdebug);
 
 my @a = $schema->resultset("Artist")->search(
   { },
@@ -99,7 +98,7 @@
 
 is($queries, 1, 'only one SQL statement executed');
 
-$schema->storage->debug(0);
+$schema->storage->debug($sdebug);
 
 # make sure related_resultset is deleted after object is updated
 $artist->set_column('name', 'New Name');
@@ -136,7 +135,7 @@
 
 is($queries, 1, 'only one SQL statement executed');
 
-$schema->storage->debug(0);
+$schema->storage->debug($sdebug);
 
 my @objs;
 #$artist = $rs->find(1);
@@ -185,5 +184,5 @@
 
 is( $queries, 1, 'only one select statement on find with has_many prefetch on resultset' );
 
-$schema->storage->debug(0);
+$schema->storage->debug($sdebug);
 

Modified: DBIx-Class/0.08/branches/grouped_prefetch/t/86might_have.t
===================================================================
--- DBIx-Class/0.08/branches/grouped_prefetch/t/86might_have.t	2009-06-29 07:50:43 UTC (rev 6839)
+++ DBIx-Class/0.08/branches/grouped_prefetch/t/86might_have.t	2009-06-29 08:07:09 UTC (rev 6840)
@@ -8,14 +8,11 @@
 my $schema = DBICTest->init_schema();
 
 my $queries;
-#$schema->storage->debugfh(IO::File->new('t/var/temp.trace', 'w'));
 $schema->storage->debugcb( sub{ $queries++ } );
+my $sdebug = $schema->storage->debug;
 
-eval "use DBD::SQLite";
-plan skip_all => 'needs DBD::SQLite for testing' if $@;
 plan tests => 2;
 
-
 my $cd = $schema->resultset("CD")->find(1);
 $cd->title('test');
 
@@ -28,7 +25,7 @@
 is($queries, 1, 'liner_notes (might_have) not prefetched - do not load 
 liner_notes on update');
 
-$schema->storage->debug(0);
+$schema->storage->debug($sdebug);
 
 
 my $cd2 = $schema->resultset("CD")->find(2, {prefetch => 'liner_notes'});
@@ -43,5 +40,4 @@
 is($queries, 1, 'liner_notes (might_have) prefetched - do not load 
 liner_notes on update');
 
-$schema->storage->debug(0);
-
+$schema->storage->debug($sdebug);

Modified: DBIx-Class/0.08/branches/grouped_prefetch/t/prefetch/grouped.t
===================================================================
--- DBIx-Class/0.08/branches/grouped_prefetch/t/prefetch/grouped.t	2009-06-29 07:50:43 UTC (rev 6839)
+++ DBIx-Class/0.08/branches/grouped_prefetch/t/prefetch/grouped.t	2009-06-29 08:07:09 UTC (rev 6840)
@@ -10,6 +10,7 @@
 plan 'no_plan';
 
 my $schema = DBICTest->init_schema();
+my $sdebug = $schema->storage->debug;
 
 my $cd_rs = $schema->resultset('CD')->search (
   { 'tracks.cd' => { '!=', undef } },
@@ -47,6 +48,7 @@
   {
     my $query_cnt = 0;
     $schema->storage->debugcb ( sub { $query_cnt++ } );
+    $schema->storage->debug (1);
 
     $track_rs->reset;
     while (my $collapsed_track = $track_rs->next) {
@@ -57,6 +59,7 @@
 
     is ($query_cnt, 0, 'No queries on prefetched titles');
     $schema->storage->debugcb (undef);
+    $schema->storage->debug ($sdebug);
   }
 
   # Test sql by hand, as the sqlite db will simply paper over
@@ -184,6 +187,7 @@
 
   my $query_cnt = 0;
   $schema->storage->debugcb ( sub { $query_cnt++ } );
+  $schema->storage->debug (1);
 
   is ($top_cd->get_column ('track_count'), 4, 'Track count fetched correctly');
   is ($top_cd->tracks->count, 4, 'Count of prefetched tracks rs still correct');
@@ -196,4 +200,5 @@
 
   is ($query_cnt, 0, 'No queries executed during prefetched data access');
   $schema->storage->debugcb (undef);
+  $schema->storage->debug ($sdebug);
 }

Modified: DBIx-Class/0.08/branches/grouped_prefetch/t/prefetch/multiple_hasmany.t
===================================================================
--- DBIx-Class/0.08/branches/grouped_prefetch/t/prefetch/multiple_hasmany.t	2009-06-29 07:50:43 UTC (rev 6839)
+++ DBIx-Class/0.08/branches/grouped_prefetch/t/prefetch/multiple_hasmany.t	2009-06-29 08:07:09 UTC (rev 6840)
@@ -5,13 +5,13 @@
 use Test::Exception;
 use lib qw(t/lib);
 use DBICTest;
-use Data::Dumper;
+use IO::File;
 
 plan tests => 10;
 
 my $schema = DBICTest->init_schema();
+my $sdebug = $schema->storage->debug;
 
-use IO::File;
 
 # once the following TODO is complete, remove the 2 warning tests immediately
 # after the TODO block
@@ -44,6 +44,9 @@
     ok(! $o_mm_warn, 'no warning on attempt to prefetch several same level has_many\'s (1 -> M + M)');
 
     is($queries, 1, 'prefetch one->(has_many,has_many) ran exactly 1 query');
+    $schema->storage->debugcb (undef);
+    $schema->storage->debug ($sdebug);
+
     is($pr_tracks_count, $tracks_count, 'equal count of prefetched relations over several same level has_many\'s (1 -> M + M)');
 
     for ($pr_tracks_rs, $tracks_rs) {
@@ -79,6 +82,8 @@
     ok(! $m_o_mm_warn, 'no warning on attempt to prefetch several same level has_many\'s (M -> 1 -> M + M)');
 
     is($queries, 1, 'prefetch one->(has_many,has_many) ran exactly 1 query');
+    $schema->storage->debugcb (undef);
+    $schema->storage->debug ($sdebug);
 
     is($pr_tags_count, $tags_count, 'equal count of prefetched relations over several same level has_many\'s (M -> 1 -> M + M)');
 

Modified: DBIx-Class/0.08/branches/grouped_prefetch/t/prefetch/standard.t
===================================================================
--- DBIx-Class/0.08/branches/grouped_prefetch/t/prefetch/standard.t	2009-06-29 07:50:43 UTC (rev 6839)
+++ DBIx-Class/0.08/branches/grouped_prefetch/t/prefetch/standard.t	2009-06-29 08:07:09 UTC (rev 6840)
@@ -6,20 +6,13 @@
 use lib qw(t/lib);
 use DBICTest;
 use Data::Dumper;
+use IO::File;
 
 my $schema = DBICTest->init_schema();
-
 my $orig_debug = $schema->storage->debug;
 
-use IO::File;
+plan tests => 45;
 
-BEGIN {
-    eval "use DBD::SQLite";
-    plan $@
-        ? ( skip_all => 'needs DBD::SQLite for testing' )
-        : ( tests => 45 );
-}
-
 my $queries = 0;
 $schema->storage->debugcb(sub { $queries++; });
 $schema->storage->debug(1);
@@ -314,3 +307,5 @@
 
 is($queries, 0, 'chained search_related after has_many->has_many prefetch ran no queries');
 
+$schema->storage->debug($orig_debug);
+$schema->storage->debugobj->callback(undef);

Modified: DBIx-Class/0.08/branches/grouped_prefetch/t/relationship/core.t
===================================================================
--- DBIx-Class/0.08/branches/grouped_prefetch/t/relationship/core.t	2009-06-29 07:50:43 UTC (rev 6839)
+++ DBIx-Class/0.08/branches/grouped_prefetch/t/relationship/core.t	2009-06-29 08:07:09 UTC (rev 6840)
@@ -7,6 +7,7 @@
 use DBICTest;
 
 my $schema = DBICTest->init_schema();
+my $sdebug = $schema->storage->debug;
 
 plan tests => 78;
 
@@ -57,7 +58,7 @@
   is($queries, 0, 'No SELECT made for belongs_to if key IS NULL');
   $big_flop_cd->genre_inefficient; #should trigger a select query
   is($queries, 1, 'SELECT made for belongs_to if key IS NULL when undef_on_null_fk disabled');
-  $schema->storage->debug(0);
+  $schema->storage->debug($sdebug);
   $schema->storage->debugcb(undef);
 }
 

Modified: DBIx-Class/0.08/branches/grouped_prefetch/t/relationship/update_or_create_multi.t
===================================================================
--- DBIx-Class/0.08/branches/grouped_prefetch/t/relationship/update_or_create_multi.t	2009-06-29 07:50:43 UTC (rev 6839)
+++ DBIx-Class/0.08/branches/grouped_prefetch/t/relationship/update_or_create_multi.t	2009-06-29 08:07:09 UTC (rev 6840)
@@ -8,9 +8,9 @@
 use DBIC::SqlMakerTest;
 
 my $schema = DBICTest->init_schema();
+my $sdebug = $schema->storage->debug;
 
-#plan tests => 4;
-plan 'no_plan';
+plan tests => 6;
 
 my $artist = $schema->resultset ('Artist')->first;
 
@@ -74,6 +74,7 @@
 });
 
 $schema->storage->debugcb(undef);
+$schema->storage->debug ($sdebug);
 
 is_same_sql (
   $sql[0],

Modified: DBIx-Class/0.08/branches/grouped_prefetch/t/relationship/update_or_create_single.t
===================================================================
--- DBIx-Class/0.08/branches/grouped_prefetch/t/relationship/update_or_create_single.t	2009-06-29 07:50:43 UTC (rev 6839)
+++ DBIx-Class/0.08/branches/grouped_prefetch/t/relationship/update_or_create_single.t	2009-06-29 08:07:09 UTC (rev 6840)
@@ -7,8 +7,7 @@
 
 my $schema = DBICTest->init_schema();
 
-#plan tests => 4;
-plan 'no_plan';
+plan tests => 9;
 
 my $artist = $schema->resultset ('Artist')->first;
 




More information about the Bast-commits mailing list