| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mail::Action::StorageTest; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
653
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
37
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
32
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base 'Test::Class'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1115
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
37094
|
use Test::More; |
|
|
1
|
|
|
|
|
6468
|
|
|
|
1
|
|
|
|
|
11
|
|
|
9
|
1
|
|
|
1
|
|
1085
|
use Test::Exception; |
|
|
1
|
|
|
|
|
2978
|
|
|
|
1
|
|
|
|
|
4
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
263
|
use File::Path; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
56
|
|
|
12
|
1
|
|
|
1
|
|
4
|
use File::Spec; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
117
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
11
|
|
|
11
|
0
|
28
|
sub module { 'Mail::Action::Storage' } |
|
15
|
1
|
|
|
1
|
0
|
3
|
sub subclass { 'Mail::Action::StorageSub' } |
|
16
|
12
|
|
|
12
|
0
|
744
|
sub storage_dir { 'storage' } |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub startup :Test( startup => 2 ) |
|
19
|
|
|
|
|
|
|
{ |
|
20
|
1
|
|
|
1
|
0
|
2557
|
my $self = shift; |
|
21
|
1
|
|
|
|
|
5
|
my $module = $self->module(); |
|
22
|
1
|
|
|
|
|
5
|
my $storage_dir = $self->storage_dir(); |
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
7
|
use_ok( $module ); |
|
|
1
|
|
|
|
|
145
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
16
|
|
|
25
|
1
|
|
|
|
|
651
|
can_ok( $module, 'new' ); |
|
26
|
|
|
|
|
|
|
|
|
27
|
1
|
50
|
|
|
|
69239
|
mkdir $storage_dir unless -d $storage_dir; |
|
28
|
1
|
|
|
1
|
|
6
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub shutdown :Test( shutdown ) |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
1
|
|
|
1
|
1
|
891
|
my $self = shift; |
|
33
|
1
|
50
|
|
|
|
10
|
rmtree $self->storage_dir() unless $ENV{PERL_TEST_DEBUG}; |
|
34
|
1
|
|
|
1
|
|
325
|
} |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
5
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub setup :Test( setup => 1 ) |
|
37
|
|
|
|
|
|
|
{ |
|
38
|
9
|
|
|
9
|
0
|
7225
|
my $self = shift; |
|
39
|
9
|
|
|
|
|
28
|
my $module = $self->module(); |
|
40
|
|
|
|
|
|
|
|
|
41
|
9
|
|
|
|
|
25
|
$self->{storage} = $module->new( $self->storage_dir() ); |
|
42
|
9
|
|
|
|
|
77
|
isa_ok( $self->{storage}, $module ); |
|
43
|
1
|
|
|
1
|
|
264
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
3
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub test_new_exception :Test |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
1
|
|
|
1
|
0
|
735
|
my $self = shift; |
|
48
|
1
|
|
|
|
|
4
|
my $module = $self->module(); |
|
49
|
|
|
|
|
|
|
|
|
50
|
1
|
|
|
1
|
|
16
|
throws_ok { $module->new() } qr/No storage directory/, |
|
|
1
|
|
|
|
|
43
|
|
|
51
|
|
|
|
|
|
|
'new() should throw exception without directory given'; |
|
52
|
1
|
|
|
1
|
|
249
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub test_fetch :Test( 3 ) |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
1
|
|
|
1
|
0
|
657
|
my $self = shift; |
|
57
|
1
|
|
|
|
|
3
|
my $storage = $self->{storage}; |
|
58
|
1
|
|
|
|
|
5
|
my $storage_class = $self->subclass(); |
|
59
|
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
14
|
my $s = $storage_class->new( 'storage' ); |
|
61
|
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
3
|
can_ok( $storage, 'fetch' ); |
|
63
|
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
524
|
$storage->save( { foo => 'bar', baz => 'quux', name => 'why' }, 'why' ); |
|
65
|
1
|
|
|
|
|
21908
|
my $result = $s->fetch( 'why' ); |
|
66
|
1
|
|
|
|
|
28
|
is_deeply( $result, { foo => 'bar', baz => 'quux', name => 'why' }, |
|
67
|
|
|
|
|
|
|
'fetch() should return loaded data' ); |
|
68
|
1
|
|
|
|
|
2281
|
isa_ok( $result, $s->stored_class(), '... blessed into storage class' ); |
|
69
|
1
|
|
|
1
|
|
292
|
} |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
4
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub test_storage_dir :Test( 2 ) |
|
72
|
|
|
|
|
|
|
{ |
|
73
|
1
|
|
|
1
|
0
|
685
|
my $self = shift; |
|
74
|
1
|
|
|
|
|
3
|
my $storage = $self->{storage}; |
|
75
|
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
5
|
can_ok( $storage, 'storage_dir' ); |
|
77
|
1
|
|
|
|
|
544
|
is( $storage->storage_dir(), $self->storage_dir(), |
|
78
|
|
|
|
|
|
|
'storage_dir() should return directory set in constructor' ); |
|
79
|
1
|
|
|
1
|
|
230
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub test_stored_class :Test( 2 ) |
|
82
|
|
|
|
|
|
|
{ |
|
83
|
1
|
|
|
1
|
0
|
730
|
my $self = shift; |
|
84
|
1
|
|
|
|
|
3
|
my $storage = $self->{storage}; |
|
85
|
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
4
|
can_ok( $storage, 'stored_class' ); |
|
87
|
1
|
|
|
|
|
534
|
is( $storage->stored_class(), '', 'stored_class() should be blank' ); |
|
88
|
1
|
|
|
1
|
|
239
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub test_storage_extension :Test( 2 ) |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
1
|
|
|
1
|
0
|
686
|
my $self = shift; |
|
93
|
1
|
|
|
|
|
3
|
my $storage = $self->{storage}; |
|
94
|
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
3
|
can_ok( $storage, 'storage_extension' ); |
|
96
|
1
|
|
|
|
|
641
|
is( $storage->storage_extension(), 'mas', |
|
97
|
|
|
|
|
|
|
'storage_extension() should be mas' ); |
|
98
|
1
|
|
|
1
|
|
234
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
3
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub test_storage_file :Test( 2 ) |
|
101
|
|
|
|
|
|
|
{ |
|
102
|
1
|
|
|
1
|
0
|
768
|
my $self = shift; |
|
103
|
1
|
|
|
|
|
3
|
my $storage = $self->{storage}; |
|
104
|
|
|
|
|
|
|
|
|
105
|
1
|
|
|
|
|
47
|
can_ok( $storage, 'storage_file' ); |
|
106
|
1
|
|
|
|
|
613
|
is( $storage->storage_file( 'foo' ), |
|
107
|
|
|
|
|
|
|
File::Spec->catfile( 'storage', 'foo.mas' ), |
|
108
|
|
|
|
|
|
|
'storage_file() should return directory path of file with extension' ); |
|
109
|
1
|
|
|
1
|
|
235
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub test_create :Test |
|
112
|
|
|
|
|
|
|
{ |
|
113
|
1
|
|
|
1
|
0
|
1015
|
my $self = shift; |
|
114
|
1
|
|
|
|
|
4
|
my $storage = $self->{storage}; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# empty body, just exists |
|
117
|
1
|
|
|
|
|
5
|
can_ok( $storage, 'create' ); |
|
118
|
1
|
|
|
1
|
|
285
|
} |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
6
|
|
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub test_exists :Test( 2 ) |
|
121
|
|
|
|
|
|
|
{ |
|
122
|
1
|
|
|
1
|
0
|
707
|
my $self = shift; |
|
123
|
1
|
|
|
|
|
3
|
my $storage = $self->{storage}; |
|
124
|
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
4
|
can_ok( $storage, 'exists' ); |
|
126
|
1
|
|
|
|
|
566
|
ok( ! $storage->exists( 'foo' ), |
|
127
|
|
|
|
|
|
|
'exists() should return false unless stored object exists' ); |
|
128
|
1
|
|
|
1
|
|
269
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
3
|
|
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub test_save :Test( 2 ) |
|
131
|
|
|
|
|
|
|
{ |
|
132
|
1
|
|
|
1
|
0
|
676
|
my $self = shift; |
|
133
|
1
|
|
|
|
|
4
|
my $storage = $self->{storage}; |
|
134
|
|
|
|
|
|
|
|
|
135
|
1
|
|
|
|
|
6
|
can_ok( $storage, 'save' ); |
|
136
|
|
|
|
|
|
|
|
|
137
|
1
|
|
|
|
|
545
|
$storage->save( { foo => 'bar', baz => 'quux', name => 'eks' }, 'eks' ); |
|
138
|
1
|
|
|
|
|
1350
|
ok( $storage->exists( 'eks' ), |
|
139
|
|
|
|
|
|
|
'save() should store file checkable with exists' ); |
|
140
|
1
|
|
|
1
|
|
245
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
package Mail::Action::RealAddress; |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub new |
|
145
|
|
|
|
|
|
|
{ |
|
146
|
1
|
|
|
1
|
|
13860
|
my ($class, %args) = @_; |
|
147
|
1
|
|
|
|
|
10
|
bless \%args, $class; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
package Mail::Action::StorageSub; |
|
151
|
|
|
|
|
|
|
|
|
152
|
1
|
|
|
1
|
|
217
|
use base 'Mail::Action::Storage'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
723
|
|
|
153
|
|
|
|
|
|
|
|
|
154
|
2
|
|
|
2
|
|
14
|
sub stored_class { 'Mail::Action::RealAddress' } |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
1; |