/[Frey]/branches/zimbardo/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

Contents of /branches/zimbardo/t/01-Frey-Storage.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1189 - (show annotations)
Mon Sep 28 20:23:45 2009 UTC (14 years, 7 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1060 byte(s)
use Storage to store files with exstension .st(orgage)
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use Test::More tests => 21;
6 use lib 'lib';
7
8 use Data::Dump qw/dump/;
9
10 my $debug = @ARGV ? 1 : 0;
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 foreach my $path ( map { "var/t/Frey.Storage.$_" } ( 'yaml', 'storable' ) ) {
31
32 diag $path;
33
34 my $data = { foo => 'bar' };
35
36 ok( $o->store( $path, $data ), 'store' );
37
38 ok( my $data2 = $o->load( $path ), 'load' );
39
40 diag dump( $data, $data2 ) if $debug;
41 is_deeply( $data, $data2, 'same' );
42
43 ok( ! $o->reload( $path ), 'no reload' );
44
45 sleep 1;
46
47 $data->{baz} = 42;
48 ok( $o->store( $path, $data ), 'store again' );
49
50 ok( my $new = $o->reload( $path ), 'reload' );
51
52 diag dump( $data, $new ) if $debug;
53 is_deeply( $data, $new, 'same' );
54
55 ok( ! $o->reload( $path ), 'no reload' );
56
57 } # foreach
58
59 ok( ! $o->load( 'var/something.which.doesnt.exist' ), 'load without file' );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26