added test to make sure you can override the default attributes to discard_changes
[dbsrgits/DBIx-Class.git] / t / 93storage_replication.t
index f1743c5..53e9fc9 100644 (file)
@@ -13,7 +13,7 @@ BEGIN {
     eval "use DBIx::Class::Storage::DBI::Replicated; use Test::Moose";
     plan $@
         ? ( skip_all => "Deps not installed: $@" )
-        : ( tests => 126 );
+        : ( tests => 132 );
 }
 
 use_ok 'DBIx::Class::Storage::DBI::Replicated::Pool';
@@ -21,6 +21,10 @@ use_ok 'DBIx::Class::Storage::DBI::Replicated::Balancer';
 use_ok 'DBIx::Class::Storage::DBI::Replicated::Replicant';
 use_ok 'DBIx::Class::Storage::DBI::Replicated';
 
+use Moose();
+use MooseX::Types();
+diag "Using Moose version $Moose::VERSION and MooseX::Types version $MooseX::Types::VERSION";
+
 =head1 HOW TO USE
 
     This is a test of the replicated storage system.  This will work in one of
@@ -757,10 +761,24 @@ is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{d
        is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{dsn}";
 
        ok $artist->get_from_storage({force_pool=>'master'})
-          => 'properly discard changes';
+          => 'properly called get_from_storage against master (manual attrs)';
+
+       is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
+
+       ok $artist->discard_changes({force_pool=>'master'})
+          => 'properly called discard_changes against master (manual attrs)';
 
        is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
 
+       ok $artist->discard_changes()
+          => 'properly called discard_changes against master (default attrs)';
+
+       is $debug{storage_type}, 'MASTER', "got last query from a master: $debug{dsn}";
+
+       ok $artist->discard_changes({force_pool=>$replicant_names[0]})
+          => 'properly able to override the default attributes';
+
+       is $debug{storage_type}, 'REPLICANT', "got last query from a replicant: $debug{dsn}"
 }
 
 ## Test some edge cases, like trying to do a transaction inside a transaction, etc