Memcached/t/CHIDriverTests/Base.pm

filter: Statementstmt 53.5% 30 / 56 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.9% 9 / 22 Podpod 0.0% 0 / 12 totaltotal 41.4% 39 / 94 SCAR 17.9
CC
4
Cov
50%
set_standard_keys_and_values
12.0
connect_to_memcached
6.0
supports_get_namespaces
2.0
CRAP 6.0
« Memcached/Base.pm ↑ Summary Memcached/Test/Driver.pm »
1 package CHI::Driver::Memcached::t::CHIDriverTests::Base;
2 3 $CHI::Driver::Memcached::t::CHIDriverTests::Base::VERSION = '0.15';
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use CHI::Test;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use base qw(CHI::t::Driver);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 __PACKAGE__->SKIP_CLASS("abstract base class");
9  
10 3 my $testaddr = "127.0.0.1:11211";
11  
12 sub required_modules {
13 3 ▶ my $class = shift;
Subroutine required_modules: called CC=1 SCAR=0.0
Pod undocumented
14 return {
15 3 $class->testing_driver_class => undef,
16 $class->memcached_class => undef,
17 'IO::Socket::INET' => undef
18 };
19 }
20  
21 0 ▶sub supports_get_namespaces { 0 }
Subroutine supports_get_namespaces: not called CC=1 SCAR=6.9
Pod undocumented
22 0 ▶sub supports_expires_on_backend { 1 }
Subroutine supports_expires_on_backend: not called CC=1 SCAR=6.9
Pod undocumented
23  
24 sub connect_to_memcached : Test(startup) {
25 0 ▶ my $self = shift;
Subroutine connect_to_memcached: not called CC=2 SCAR=17.9
Pod undocumented
26 0 require IO::Socket::INET;
27 0 my $msock = IO::Socket::INET->new(
28 PeerAddr => $testaddr,
29 Timeout => 3
30 );
31 0 ▶ if ( !$msock ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $msock) 0 0 0
32 0 $self->SKIP_ALL("No memcached instance running at $testaddr");
33 }
34 3 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 sub clear_memcached : Test(setup) {
37 0 ▶ my ($self) = @_;
Subroutine clear_memcached: not called CC=1 SCAR=6.9
Pod undocumented
38  
39 0 my $cache = $self->new_cache();
40 0 $cache->memd->flush_all();
41 3 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 sub new_cache_options {
44 0 ▶ my $self = shift;
Subroutine new_cache_options: not called CC=1 SCAR=6.9
Pod undocumented
45  
46 # CHI::Driver::Memcached::Test::Driver defines get_keys for testing purposes
47 return (
48 0 $self->SUPER::new_cache_options(),
49 driver => undef,
50 driver_class => $self->test_driver_class(),
51 servers => [$testaddr]
52 );
53 }
54  
55 sub set_standard_keys_and_values {
56 0 ▶ my ($self) = @_;
Subroutine set_standard_keys_and_values: not called CC=3 SCAR=24.8
Pod undocumented
57  
58 0 my ( $keys, $values ) = $self->SUPER::set_standard_keys_and_values();
59  
60 # memcached keys have max length of 250, plus we're adding namespace
61 0 $keys->{'large'} = scalar( 'ab' x 100 );
62  
63 # memcached keys must not include control characters or whitespace
64 0 foreach my $key (qw(space mixed binary newline arrayref hashref utf8)) {
65 0 ▶ $keys->{$key} = $key if defined( $keys->{$key} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $keys->{$key} 0 0 0
66 }
67  
68 0 return ( $keys, $values );
69 }
70  
71 # TODO - Not working right now - fix later
72 ▶sub test_size_awareness_with_subcaches { }
Subroutine test_size_awareness_with_subcaches: not called CC=1 SCAR=0.0
Pod undocumented
73 ▶sub test_max_size_with_l1_cache { }
Subroutine test_max_size_with_l1_cache: not called CC=1 SCAR=0.0
Pod undocumented
74 ▶sub test_encode { }
Subroutine test_encode: not called CC=1 SCAR=0.0
Pod undocumented
75  
76 sub test_get_keys : Test(1) {
77 0 ▶ my $self = shift;
Subroutine test_get_keys: not called CC=1 SCAR=6.9
Pod undocumented
78  
79 # Make sure we get a 'not supported' error with regular memcached driver
80 0 my $cache = $self->SUPER::new_cache(
81 driver_class => $self->testing_driver_class(),
82 servers => [$testaddr]
83 );
84 throws_ok(
85 0 ▶ sub { $cache->get_keys() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
86 0 qr/not supported/,
87 "get_keys not supported"
88 );
89 3 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
90  
91 sub test_namespaces : Test(1) {
92 0 ▶ my $self = shift;
Subroutine test_namespaces: not called CC=1 SCAR=6.9
Pod undocumented
93  
94 # Make sure we get a 'not supported' error with regular memcached driver
95 0 my $cache = $self->SUPER::new_cache(
96 driver_class => $self->testing_driver_class(),
97 servers => [$testaddr]
98 );
99 throws_ok(
100 0 ▶ sub { $cache->get_namespaces() },
Subroutine __ANON__: not called CC=1 SCAR=6.9
101 0 qr/not supported/,
102 "get_keys not supported"
103 );
104 3 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
105  
106 3 1;
« Memcached/Base.pm ↑ Summary Memcached/Test/Driver.pm »