use Test::Moose;
use Test::Exception;
-use List::Util 'first';
use Scalar::Util 'reftype';
-use File::Spec;
use Moose();
use MooseX::Types();
note "Using Moose version $Moose::VERSION and MooseX::Types version $MooseX::Types::VERSION";
-my $var_dir = quotemeta ( File::Spec->catdir(qw/t var/) );
+my $var_dir_re = qr{ t [\/\\] var [\/\\] }x;
## Add a connect_info option to test option merging.
use DBIx::Class::Storage::DBI::Replicated;
$self->master_path( DBICTest->_sqlite_dbfilename );
$self->slave_paths([
- File::Spec->catfile(qw/t var DBIxClass_slave1.db/),
- File::Spec->catfile(qw/t var DBIxClass_slave2.db/),
+ 't/var/DBIxClass_slave1.db',
+ 't/var/DBIxClass_slave2.db',
]);
return $self;
## Silence warning about not supporting the is_replicating method if using the
## sqlite dbs.
$replicated->schema->storage->debugobj->silence(1)
- if first { $_ =~ /$var_dir/ } @replicant_names;
+ if grep { $_ =~ $var_dir_re } @replicant_names;
isa_ok $replicated->schema->storage->balancer->current_replicant
=> 'DBIx::Class::Storage::DBI';
## Silence warning about not supporting the is_replicating method if using the
## sqlite dbs.
$replicated->schema->storage->debugobj->silence(1)
- if first { $_ =~ /$var_dir/ } @replicant_names;
+ if grep { $_ =~ $var_dir_re } @replicant_names;
$replicated->schema->storage->pool->validate_replicants;
## Silence warning about not supporting the is_replicating method if using the
## sqlite dbs.
$replicated->schema->storage->debugobj->silence(1)
- if first { $_ =~ /$var_dir/ } @replicant_names;
+ if grep { $_ =~ $var_dir_re } @replicant_names;
$replicated->schema->storage->pool->validate_replicants;
is $debug{storage_type}, 'MASTER',
"got last query from a master: $debug{dsn}";
+ $_[1] = 9;
+
} => 'created coderef properly';
-$replicated->schema->storage->execute_reliably($reliably);
+my @list_to_mangle = (1, 2, 3);
+
+$replicated->schema->storage->execute_reliably($reliably, @list_to_mangle);
+
+is_deeply
+ \@list_to_mangle,
+ [ 1, 9, 3],
+ 'Aliasing of values passed to execute_reliably works'
+;
## Try something with an error
qr/Can't find source for ArtistXX/
=> 'Bad coderef throws proper error';
+throws_ok {
+ $replicated->schema->storage->execute_reliably(sub{
+ die bless [], 'SomeExceptionThing';
+ });
+} 'SomeExceptionThing', "Blessed exception kept intact";
+
## Make sure replication came back
ok $replicated->schema->resultset('Artist')->find(3)