/[A3C]/t/05-cache.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /t/05-cache.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 227 - (hide annotations)
Fri Jun 27 17:53:30 2008 UTC (14 years ago) by dpavlin
File MIME type: application/x-troff
File size: 1089 byte(s)
Added dir to specify directory in application's var/
in which cache files will go.
1 dpavlin 219 #!/usr/bin/env perl
2     use warnings;
3     use strict;
4    
5     =head1 DESCRIPTION
6    
7     test cache
8    
9     =cut
10    
11     use Jifty::Test tests => 11;
12    
13     use Data::Dump qw/dump/;
14    
15     use_ok('A3C::Cache');
16    
17     $A3C::Cache::debug = 1 if @ARGV;
18     my $debug = $A3C::Cache::debug;
19    
20     my $instance = 'cache';
21    
22 dpavlin 227 ok( my $strix = A3C::Cache->new({ instance => $instance, dir => 't' }), 'new' );
23 dpavlin 219 isa_ok( $strix, 'A3C::Cache' );
24    
25     # cache
26     ok( my $path = $strix->cache_path( 'test', 42, 'bar' ), 'cache_path' );
27 dpavlin 227 like( $path, qr'var/t/.*test-42-bar', 'correct' );
28     diag "path: $path";
29 dpavlin 219
30     my $data = 'scalar';
31     SKIP: {
32     skip( 'scalars not supported', 2 );
33     ok( $strix->write_cache( $data, 'test-scalar' ), 'write_cache scalar' );
34     is_deeply( $strix->read_cache( 'test-scalar' ), $data, 'read_cache scalar' );
35     }
36     $data = { foo => 42, bar => 'baz' };
37     ok( $strix->write_cache( $data, 'test-hash' ), 'write_cache hash' );
38     is_deeply( $strix->read_cache( 'test-hash' ), $data, 'read_cache hash' );
39     $data = [ 1, 2, 42 ];
40     ok( $strix->write_cache( $data, 'test-array' ), 'write_cache array' );
41     is_deeply( $strix->read_cache( 'test-array' ), $data, 'read_cache array' );
42    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26