File: leak.t

package info (click to toggle)
libanyevent-redis-perl 0.24-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 248 kB
  • ctags: 142
  • sloc: perl: 1,888; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 994 bytes parent folder | download | duplicates (5)
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
use strict;
use Test::More;
use t::Redis;

BEGIN {
  eval q{use Test::LeakTrace};
  plan skip_all => "Test::LeakTrace required" if $@;
}

test_redis {
    my $r = shift;
    my $port = shift;
    $r->all_cv->begin(sub { $_[0]->send });

    if($r->info->recv->{redis_version} ge "1.3.0") {

      # Set values used later
      no_leaks_ok {
        $r->multi;
        $r->set("foo$_" => "bar$_") for 1 .. 10;
        $r->exec->recv;
      } "multi/set";

      # Check values
      no_leaks_ok {
        $r->multi;
        $r->mget(map { "foo$_" } 1 .. 5);
        $r->mget(map { "foo$_" } 6 .. 10);
        my $res = $r->exec->recv;
      } "multi/mget";

      # Reproduce github issue 6:
      # http://github.com/miyagawa/AnyEvent-Redis/issues/issue/6
      no_leaks_ok {
        $r->blpop('a' .. 'z', 1)->recv;
      } "blpop";

      $r->all_cv->end;
      $r->all_cv->recv;
      done_testing;

    } else {
      plan skip_all => "No support for MULTI in this server version";
    }
};