line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CHI::t::GetError; |
2
|
|
|
|
|
|
|
$CHI::t::GetError::VERSION = '0.61'; |
3
|
1
|
|
|
1
|
|
560
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
5
|
1
|
|
|
1
|
|
414
|
use CHI::Test; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
6
|
1
|
|
|
1
|
|
8
|
use CHI::Test::Util qw(activate_test_logger); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
55
|
|
7
|
1
|
|
|
1
|
|
5
|
use base qw(CHI::Test::Class); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
721
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub writeonly_cache { |
10
|
5
|
|
|
5
|
0
|
13
|
my ($on_get_error) = @_; |
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
|
|
24
|
return CHI->new( |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# leave as driver_class rather than driver to test back compat |
15
|
|
|
|
|
|
|
driver_class => 'CHI::Test::Driver::Writeonly', |
16
|
|
|
|
|
|
|
on_get_error => $on_get_error, |
17
|
|
|
|
|
|
|
global => 1, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub test_get_errors : Tests { |
22
|
1
|
|
|
1
|
0
|
1380
|
my ( $key, $value ) = ( 'medium', 'medium' ); |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
4
|
my $error_pattern = |
25
|
|
|
|
|
|
|
qr/error during cache get for namespace='.*', key='medium'.*: write-only cache/; |
26
|
1
|
|
|
|
|
5
|
my $log = activate_test_logger(); |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
3
|
my $cache; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
4
|
$cache = writeonly_cache('ignore'); |
31
|
1
|
|
|
|
|
9
|
$cache->set( $key, $value ); |
32
|
1
|
|
|
|
|
9
|
ok( !defined( $cache->get($key) ), "ignore - miss" ); |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
573
|
$cache = writeonly_cache('die'); |
35
|
1
|
|
|
|
|
5
|
$cache->set( $key, $value ); |
36
|
1
|
|
|
1
|
|
10
|
throws_ok( sub { $cache->get($key) }, $error_pattern, "die - dies" ); |
|
1
|
|
|
|
|
44
|
|
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
944
|
$log->clear(); |
39
|
1
|
|
|
|
|
17
|
$cache = writeonly_cache('log'); |
40
|
1
|
|
|
|
|
5
|
$cache->set( $key, $value ); |
41
|
1
|
|
|
|
|
5
|
ok( !defined( $cache->get($key) ), "log - miss" ); |
42
|
1
|
|
|
|
|
330
|
$log->contains_ok(qr/cache set for .* key='medium'/); |
43
|
1
|
|
|
|
|
365
|
$log->contains_ok($error_pattern); |
44
|
1
|
|
|
|
|
363
|
$log->empty_ok(); |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
312
|
my ( $err_msg, $err_key ); |
47
|
|
|
|
|
|
|
$cache = writeonly_cache( |
48
|
|
|
|
|
|
|
sub { |
49
|
1
|
|
|
1
|
|
3
|
( $err_msg, $err_key ) = @_; |
50
|
|
|
|
|
|
|
} |
51
|
1
|
|
|
|
|
9
|
); |
52
|
1
|
|
|
|
|
5
|
$cache->set( $key, $value ); |
53
|
1
|
|
|
|
|
4
|
ok( !defined( $cache->get($key) ), "custom - miss" ); |
54
|
1
|
|
|
|
|
328
|
like( $err_msg, $error_pattern, "custom - got msg" ); |
55
|
1
|
|
|
|
|
327
|
is( $err_key, $key, "custom - got key" ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
throws_ok( |
58
|
1
|
|
|
1
|
|
36
|
sub { writeonly_cache('bad') }, |
59
|
1
|
|
|
|
|
343
|
qr/Validation failed for|isa check for .* failed/, |
60
|
|
|
|
|
|
|
"bad - dies" |
61
|
|
|
|
|
|
|
); |
62
|
1
|
|
|
1
|
|
11
|
} |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |