return $fire;
},
- ($ENV{DBICTEST_MEMCACHED})
- ? do {
- require Cache::Memcached;
- my $memcached = Cache::Memcached->new(
- { servers => [ $ENV{DBICTEST_MEMCACHED} ] } );
-
- my $key = 'tmp_dbic_84serialize_memcached_test';
-
- ( memcached => sub {
- $memcached->set( $key, $_[0], 60 );
- local $DBIx::Class::ResultSourceHandle::thaw_schema = $schema;
- return $memcached->get($key);
- });
- } : ()
- ,
);
+if ($ENV{DBICTEST_MEMCACHED}) {
+ if (DBIx::Class::Optional::Dependencies->req_ok_for ('test_memcached')) {
+ my $memcached = Cache::Memcached->new(
+ { servers => [ $ENV{DBICTEST_MEMCACHED} ] }
+ );
+
+ my $key = 'tmp_dbic_84serialize_memcached_test';
+
+ $stores{memcached} = sub {
+ $memcached->set( $key, $_[0], 60 );
+ local $DBIx::Class::ResultSourceHandle::thaw_schema = $schema;
+ return $memcached->get($key);
+ };
+ }
+ else {
+ SKIP: {
+ skip 'Memcached tests need ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_memcached'), 1;
+ }
+ }
+}
+else {
+ SKIP: {
+ skip 'Set $ENV{DBICTEST_MEMCACHED} to run the memcached serialization tests', 1;
+ }
+}
+
+
+
for my $name (keys %stores) {
my $store = $stores{$name};
$schema->storage->debugcb(undef);
}
+# test schema-less detached thaw
+{
+ my $artist = $schema->resultset('Artist')->find(1);
+
+ $artist = dclone $artist;
+
+ is( $artist->name, 'Caterwauler McCrae', 'getting column works' );
+
+ ok( $artist->update, 'Non-dirty update noop' );
+
+ ok( $artist->name( 'Beeeeeeees' ), 'setting works' );
+
+ ok( $artist->is_column_changed( 'name' ), 'Column dirtyness works' );
+ ok( $artist->is_changed, 'object dirtyness works' );
+
+ my $rs = $artist->result_source->resultset;
+ $rs->set_cache([ $artist ]);
+
+ is( $rs->count, 1, 'Synthetic resultset count works' );
+
+ my $exc = qr/Unable to perform storage-dependent operations with a detached result source.+use \$schema->thaw/;
+
+ throws_ok { $artist->update }
+ $exc,
+ 'Correct exception on row op'
+ ;
+
+ throws_ok { $artist->discard_changes }
+ $exc,
+ 'Correct exception on row op'
+ ;
+
+ throws_ok { $rs->find(1) }
+ $exc,
+ 'Correct exception on rs op'
+ ;
+}
+
done_testing;