/[Frey]/trunk/t/01-frey-storage.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 /trunk/t/01-frey-storage.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 151 - (hide annotations)
Wed Jul 16 23:04:22 2008 UTC (15 years, 9 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1008 byte(s)
Frey::Storage to save files on disk (and reload them)
1 dpavlin 151 #!/usr/bin/perl
2     use strict;
3     use warnings;
4    
5     use Test::More tests => 13;
6     use lib 'lib';
7    
8     use Data::Dump qw/dump/;
9    
10     my $debug = 1 if @ARGV;
11    
12     BEGIN {
13     use_ok('Frey::Storage');
14     use_ok('Frey');
15     }
16    
17     {
18     package Mock;
19     use Moose;
20     extends 'Frey';
21     with 'Frey::Storage';
22     }
23    
24     isa_ok( Frey::Storage->meta, 'Moose::Meta::Role' );
25    
26    
27     ok( my $o = Mock->new( debug => $debug ), 'new' );
28     diag $o->dump(2) if $debug;
29    
30     my $data = { foo => 'bar' };
31     my $path = 'var/test.Frey.Storeage';
32    
33     ok( $o->store( $path, $data ), 'store' );
34    
35     ok( my $data2 = $o->load( $path ), 'load' );
36    
37     diag dump( $data, $data2 ) if $debug;
38     is_deeply( $data, $data2, 'same' );
39    
40     ok( ! $o->reload( $path ), 'no reload' );
41    
42     sleep 1;
43    
44     $data->{baz} = 42;
45     ok( $o->store( $path, $data ), 'store again' );
46    
47     my $new;
48     ok( $o->reload( $path, \$new ), 'reload' );
49    
50     diag dump( $data, $new ) if $debug;
51     is_deeply( $data, $new, 'same' );
52    
53     my $keep = { 'test' => 'data' };
54     my $new2 = $keep;
55     ok( ! $o->reload( $path, \$new2 ), 'reload' );
56     is_deeply( $keep, $new2, 'same' );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26