eval "use Moose; use Test::Moose";
plan $@
? ( skip_all => 'needs Moose for testing' )
- : ( tests => 71 );
+ : ( tests => 80 );
}
use_ok 'DBIx::Class::Storage::DBI::Replicated::Pool';
[ $id, "Children of the Grave"],
]);
- ok my $result = $replicated->schema->resultset('Artist')->find($id);
- ok my $more = $replicated->schema->resultset('Artist')->find(1);
-
+ ok my $result = $replicated->schema->resultset('Artist')->find($id)
+ => 'Found expected artist';
+
+ ok my $more = $replicated->schema->resultset('Artist')->find(1)
+ => 'Found expected artist again';
+
return ($result, $more);
-};
+} => 'Created a coderef properly';
## Test the transaction with multi return
{
{
ok my $result = $replicated->schema->txn_do(sub {
- ok my $more = $replicated->schema->resultset('Artist')->find(1);
+ ok my $more = $replicated->schema->resultset('Artist')->find(1)
+ => 'found inside a transaction';
return $more;
}) => 'successfully processed transaction';
ok $artist->discard_changes
=> 'properly discard changes';
}
-
+
+## Test some edge cases, like trying to do a transaction inside a transaction, etc
+
+{
+ ok my $result = $replicated->schema->txn_do(sub {
+ return $replicated->schema->txn_do(sub {
+ ok my $more = $replicated->schema->resultset('Artist')->find(1)
+ => 'found inside a transaction inside a transaction';
+ return $more;
+ });
+ }) => 'successfully processed transaction';
+
+ is $result->id, 1
+ => 'Got expected single result from transaction';
+}
+
+{
+ ok my $result = $replicated->schema->txn_do(sub {
+ return $replicated->schema->storage->execute_reliably(sub {
+ return $replicated->schema->txn_do(sub {
+ return $replicated->schema->storage->execute_reliably(sub {
+ ok my $more = $replicated->schema->resultset('Artist')->find(1)
+ => 'found inside crazy deep transactions and execute_reliably';
+ return $more;
+ });
+ });
+ });
+ }) => 'successfully processed transaction';
+
+ is $result->id, 1
+ => 'Got expected single result from transaction';
+}
+
+## Private attribute tests
+
+{
+ ok my $artist_rs = $replicated->schema->resultset('Artist')
+ => 'got artist resultset';
+
+ ## Turn on Reliable Storage
+ ok my $reliable_artist_rs = $artist_rs->search(undef, {execute_reliably=>1})
+ => 'Created a resultset using reliable storage';
+
+ ok my $artist = $reliable_artist_rs->find(2)
+ => 'got an artist to test see the attributes';
+}
+
## Delete the old database files
$replicated->cleanup;