File: CHIDriverTests.pm

package info (click to toggle)
libchi-driver-redis-perl 0.10-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 208 kB
  • sloc: perl: 1,439; makefile: 2
file content (52 lines) | stat: -rw-r--r-- 1,214 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package CHI::Driver::Redis::t::CHIDriverTests;
use strict;
use warnings;
use CHI::Test;

use base qw(CHI::t::Driver);

use Test::Mock::Redis;

sub testing_driver_class { 'CHI::Driver::Redis' }

sub supports_expires_on_backend { 1 }

sub new_cache_options {
    my $self = shift;

    return (
        $self->SUPER::new_cache_options(),
        driver_class => 'CHI::Driver::Redis',
        redis_class => (defined $ENV{CHI_REDIS_SERVER} ? 'Redis' : 'Test::Mock::Redis'),
        server => $ENV{CHI_REDIS_SERVER} || undef,
        ($ENV{CHI_REDIS_PASSWORD} ? ( password => $ENV{CHI_REDIS_PASSWORD} ) : ()),
        prefix => 'test' . $$ . ':',
    );
}

sub clear_redis : Test(setup) {
    my ($self) = @_;

    my $cache = $self->new_cache;
    $cache->redis->flushall;
}

sub test_redis_object : Tests(1) {
    my $self  = shift;
    my $cache = $self->new_cache(redis => Test::Mock::Redis->new());
    $cache->clear();
}

sub test_redis_options : Tests(1) {
    my $self  = shift;
    my $cache = $self->new_cache(redis_options => { reconnect => 2 });
    $cache->clear();
}

sub test_extra_options : Tests(1) {
    my $self  = shift;
    my $cache = $self->new_cache(reconnect => 2);
    $cache->clear();
}

1;