Harmonize DBICTEST_VIA_REPLICATED detection in tests
[dbsrgits/DBIx-Class.git] / t / admin / 03data.t
index 338771e..4be2960 100644 (file)
@@ -1,37 +1,16 @@
-#
-#===============================================================================
-#
-#         FILE:  03sql.t
-#
-#  DESCRIPTION:  test sql manipulation funtions
-#
-#        FILES:  ---
-#         BUGS:  ---
-#        NOTES:  ---
-#       AUTHOR:  Gordon Irving (), <goraxe@cpan.org>
-#      VERSION:  1.0
-#      CREATED:  12/12/09 12:44:57 GMT
-#     REVISION:  ---
-#===============================================================================
+BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
+use DBIx::Class::Optional::Dependencies -skip_all_without => 'admin';
 
 use strict;
 use warnings;
 
 use Test::More;
-
 use Test::Exception;
-use Test::Deep;
 
-BEGIN {
-    eval "use DBIx::Class::Admin";
-    plan skip_all => "Deps not installed: $@" if $@;
-}
 
-use lib 't/lib';
 use DBICTest;
 
-use ok 'DBIx::Class::Admin';
-
+use DBIx::Class::Admin;
 
 { # test data maniplulation functions
 
@@ -40,9 +19,13 @@ use ok 'DBIx::Class::Admin';
     sqlite_use_file => 1,
   );
 
+  my $storage = $schema->storage;
+  $storage = $storage->master
+    if $storage->isa('DBIx::Class::Storage::DBI::Replicated');
+
   my $admin = DBIx::Class::Admin->new(
     schema_class=> "DBICTest::Schema",
-    connect_info => $schema->storage->connect_info(),
+    connect_info => $storage->connect_info(),
     quiet  => 1,
     _confirm=>1,
   );
@@ -62,14 +45,14 @@ use ok 'DBIx::Class::Admin';
 
   $admin->insert('Employee', {name =>'Aran'});
 
-  my $expected_data = [ 
+  my $expected_data = [
     [$employee->result_source->columns() ],
-    [1,1,undef,undef,undef,'Trout'],
-    [2,2,undef,undef,undef,'Aran']
+    [1,1,undef,undef,undef,'Trout',undef],
+    [2,2,undef,undef,undef,'Aran',undef]
   ];
   my $data;
-  lives_ok { $data = $admin->select('Employee')} 'can retrive data from database';
-  cmp_deeply($data, $expected_data, 'DB matches whats expected');
+  lives_ok { $data = $admin->select('Employee', undef, { order_by => 'employee_id' })} 'can retrive data from database';
+  is_deeply($data, $expected_data, 'DB matches whats expected');
 
   $admin->delete('Employee', {name=>'Trout'});
   my $del_rs  = $employees->search({name => 'Trout'});
@@ -77,6 +60,4 @@ use ok 'DBIx::Class::Admin';
   is ($employees->count(), 1, "left Aran" );
 }
 
-
-
 done_testing;