Institute a central "load this first in testing" package
[dbsrgits/DBIx-Class-Historic.git] / t / prefetch / correlated.t
index 6c2e0b7..e941b12 100644 (file)
@@ -1,9 +1,11 @@
+BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
+
 use strict;
 use warnings;
 
 use Test::More;
 use Test::Deep;
-use lib qw(t/lib);
+
 use DBICTest ':DiffSQL';
 
 my $schema = DBICTest->init_schema();
@@ -13,7 +15,7 @@ my $cdrs = $schema->resultset('CD')->search({ 'me.artist' => { '!=', 2 }});
 my $cd_data = { map {
   $_->cdid => {
     siblings => $cdrs->search ({ artist => $_->get_column('artist') })->count - 1,
-    track_titles => [ map { $_->title } ($_->tracks->all) ],
+    track_titles => [ sort $_->tracks->get_column('title')->all ],
   },
 } ( $cdrs->all ) };
 
@@ -65,7 +67,7 @@ $schema->is_executed_querycount( sub {
   cmp_deeply (
     { map
       { $_->cdid => {
-        track_titles => [ map { $_->title } ($_->tracks->all) ],
+        track_titles => [ sort map { $_->title } ($_->tracks->all) ],
         siblings => $_->get_column ('sibling_count'),
       } }
       $c_rs->all
@@ -129,6 +131,8 @@ is_same_sql_bind(
   'Expected SQL on correlated realiased subquery'
 );
 
+$schema->storage->disconnect;
+
 # test for subselect identifier leakage
 # NOTE - the hodge-podge mix of literal and regular identifuers is *deliberate*
 for my $quote_names (0,1) {