--- t/05-cache.t 2008/06/22 14:41:23 219 +++ t/05-cache.t 2008/06/27 19:09:13 228 @@ -8,7 +8,7 @@ =cut -use Jifty::Test tests => 11; +use Jifty::Test tests => 14; use Data::Dump qw/dump/; @@ -19,12 +19,13 @@ my $instance = 'cache'; -ok( my $strix = A3C::Cache->new({ instance => $instance }), 'new' ); +ok( my $strix = A3C::Cache->new({ instance => $instance, dir => 't' }), 'new' ); isa_ok( $strix, 'A3C::Cache' ); # cache ok( my $path = $strix->cache_path( 'test', 42, 'bar' ), 'cache_path' ); -like( $path, qr/test-42-bar/, 'correct' ); +like( $path, qr'var/t/.*test-42-bar', 'correct' ); +diag "path: $path"; my $data = 'scalar'; SKIP: { @@ -32,9 +33,17 @@ ok( $strix->write_cache( $data, 'test-scalar' ), 'write_cache scalar' ); is_deeply( $strix->read_cache( 'test-scalar' ), $data, 'read_cache scalar' ); } + $data = { foo => 42, bar => 'baz' }; ok( $strix->write_cache( $data, 'test-hash' ), 'write_cache hash' ); is_deeply( $strix->read_cache( 'test-hash' ), $data, 'read_cache hash' ); + +bless $data, 'foo'; +like( ref($data), qr/foo/, 'data blessed' ); +diag "blessed = ",dump( $data ) if $debug; +ok( $strix->write_cache( $data, 'test-blessed' ), 'write_cache blessed' ); +is_deeply( $strix->read_cache( 'test-blessed' ), $data, 'read_cache blessed' ); + $data = [ 1, 2, 42 ]; ok( $strix->write_cache( $data, 'test-array' ), 'write_cache array' ); is_deeply( $strix->read_cache( 'test-array' ), $data, 'read_cache array' );