File: 51-leak.t

package info (click to toggle)
libredis-fast-perl 0.37%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 504 kB
  • sloc: perl: 2,866; makefile: 7
file content (104 lines) | stat: -rw-r--r-- 2,608 bytes parent folder | download
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
use strict;
use warnings;
use Test::More;
use Redis::Fast;
use lib 't/tlib';
use Test::SpawnRedisServer;
use Test::SharedFork;
use Socket;

use constant SSL_AVAILABLE => eval { require IO::Socket::SSL };

my ($c, $t, $srv) = redis();
my $use_ssl = $t ? SSL_AVAILABLE : 0;

END {
  $c->() if $c;
  $t->() if $t;
}

use Test::LeakTrace;

no_leaks_ok {
    my $r = Redis::Fast->new(server => $srv, ssl => $use_ssl, SSL_verify_mode => 0);
} 'Redis::Fast->new';

no_leaks_ok {
    my $r = Redis::Fast->new(server => $srv, ssl => $use_ssl, SSL_verify_mode => 0);
    my $res;
    $r->set('hogehoge', 'fugafuga');
    $res = $r->get('hogehoge');
    $r->flushdb;
} 'sync get/set';

no_leaks_ok {
    my $r = Redis::Fast->new(server => $srv, ssl => $use_ssl, SSL_verify_mode => 0);
    my $res;
    $r->set('hogehoge', 'fugafuga', sub { });
    $r->get('hogehoge', sub { $res = shift });
    $r->wait_all_responses;
    $r->flushdb;
} 'async get/set';

no_leaks_ok {
    my $r = Redis::Fast->new(server => $srv, ssl => $use_ssl, SSL_verify_mode => 0);
    my $res;
    $r->rpush('hogehoge', 'fugafuga') for (1..3);
    $res = $r->lrange('hogehoge', 0, -1);
    $r->flushdb;
} 'sync list operation';

no_leaks_ok {
    my $r = Redis::Fast->new(server => $srv, ssl => $use_ssl, SSL_verify_mode => 0);
    my $res;
    $r->rpush('hogehoge', 'fugafuga') for (1..3);
    $r->lrange('hogehoge', 0, -1, sub { $res = shift });
    $r->wait_all_responses;
    $r->flushdb;
} 'async list operation';

no_leaks_ok {
    my $r = Redis::Fast->new(server => $srv, ssl => $use_ssl, SSL_verify_mode => 0);
    my $cb = sub {};
    $r->subscribe('hogehoge', $cb);
    $r->wait_for_messages(0);
    $r->unsubscribe('hogehoge', $cb);
} 'unsubscribe';

no_leaks_ok {
    my $r = Redis::Fast->new(
        server => $srv,
        reconnect => 1,
        reconnect_on_error => sub {
            my $force_reconnect = 1;
            return $force_reconnect;
        },
        ssl => $use_ssl,
        SSL_verify_mode => 0,
    );
    eval { $r->hset(1,1) };
} 'sync reconnect_on_error';

no_leaks_ok {
    my $r = Redis::Fast->new(
        server => $srv,
        reconnect => 1,
        reconnect_on_error => sub {
            my $force_reconnect = 1;
            return $force_reconnect;
        },
        ssl => $use_ssl,
        SSL_verify_mode => 0,
    );
    my $cb = sub {};
    $r->hset(1,1,$cb);
    $r->hset(2,2,$cb);
    eval { $r->wait_all_responses };
} 'async reconnect_on_error';

no_leaks_ok {
    my $r = Redis::Fast->new(server => $srv, ssl => $use_ssl, SSL_verify_mode => 0);
    $r->info();
} 'info';

done_testing;