File: 04-pipeline-issue117.t

package info (click to toggle)
libredis-fast-perl 0.34%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 492 kB
  • sloc: perl: 2,630; makefile: 7
file content (41 lines) | stat: -rwxr-xr-x 959 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
#!perl
# Test for fixing https://github.com/shogo82148/Redis-Fast/issues/117

use warnings;
use strict;
use Test::More;
use Test::Fatal;
use Redis::Fast;
use lib 't/tlib';
use Test::SpawnRedisServer;
use Test::Deep;

my ($c, $srv) = redis();
END { $c->() if $c }
{
my $r = Redis::Fast->new(server => $srv);
eval { $r->multi( ); };
plan 'skip_all' => "multi without arguments not implemented on this redis server"  if $@ && $@ =~ /unknown command/;
}


ok(my $r = Redis::Fast->new(server => $srv, reconnect => 1), 'connected to our test redis-server');
my $r2 = Redis::Fast->new(server => $srv);

my $is_called = 0;
my $test_key = "RedisTestKey";

$r->set( $test_key => 'MyValue' );

$r->get( $test_key, sub { } );
$r2->shutdown;
$r->get( $test_key, sub { $is_called = 1; diag $_[0], $_[1] } );

eval {
    # it sometimes fails with "Connection reset by peer", but it's OK.
    $r->wait_all_responses;
};

ok $is_called, "callback is called";

done_testing();