Debian Codegraph @

t/06-on-connect.t

raw symbols SCIP
1 #!perl
2
3 use warningsscip-perl cpan Redis-Fast 0.37 warnings/;
4 use strictscip-perl cpan Redis-Fast 0.37 strict/;
5 use Test::Morescip-perl cpan Redis-Fast 0.37 Test/More/;
6 use Test::Fatalscip-perl cpan Redis-Fast 0.37 Test/Fatal/;
7 use Redis::Fastscip-perl cpan Redis-Fast 0.37 Redis/Fast/;
8 use libscip-perl cpan Redis-Fast 0.37 lib/ 't/tlib';
9 use Test::SpawnRedisServerscip-perl cpan Redis-Fast 0.37 Test/SpawnRedisServer/;
10
11 use constantscip-perl cpan Redis-Fast 0.37 constant/ SSL_AVAILABLEscip-perl cpan Redis-Fast 0.37 main/SSL_AVAILABLE(). => eval { requirescip-perl cpan Redis-Fast 0.37 main/require(). IO::Socket::SSL };
12
13 my ($c, $t, $srv) = redisscip-perl cpan Redis-Fast 0.37 main/redis().(timeout => 1);
14 my $use_ssl = $t ? SSL_AVAILABLE : 0;
15
16 END {
17 $c->()scip-perl cpan Redis-Fast 0.37 main/`->()`(). if $c;
18 $t->()scip-perl cpan Redis-Fast 0.37 main/`->()`(). if $t;
19 }
20
21 subtestscip-perl cpan Redis-Fast 0.37 main/subtest(). 'on_connect' => sub {
22 my $r;
23 okscip-perl cpan Redis-Fast 0.37 main/ok().($r = Redis::Fast->newscip-perl cpan Redis-Fast 0.37 Redis/Fast/new().(server => $srv, on_connect => sub { shift->incrscip-perl cpan Redis-Fast 0.37 shift/incr().('on_connect') }, ssl => $use_ssl, SSL_verify_mode => 0),
24 'connected to our test redis-server');
25 isscip-perl cpan Redis-Fast 0.37 main/is().($r->getscip-perl cpan Redis-Fast 0.37 Redis/Fast/get().('on_connect'), 1, '... on_connect code was run');
26
27 okscip-perl cpan Redis-Fast 0.37 main/ok().($r = Redis::Fast->newscip-perl cpan Redis-Fast 0.37 Redis/Fast/new().(server => $srv, on_connect => sub { shift->incrscip-perl cpan Redis-Fast 0.37 shift/incr().('on_connect') }, ssl => $use_ssl, SSL_verify_mode => 0),
28 'new connection is up and running');
29 isscip-perl cpan Redis-Fast 0.37 main/is().($r->getscip-perl cpan Redis-Fast 0.37 Redis/Fast/get().('on_connect'), 2, '... on_connect code was run again');
30
31 okscip-perl cpan Redis-Fast 0.37 main/ok().($r = Redis::Fast->newscip-perl cpan Redis-Fast 0.37 Redis/Fast/new().(reconnect => 1, server => $srv, on_connect => sub { shift->incrscip-perl cpan Redis-Fast 0.37 shift/incr().('on_connect') }, ssl => $use_ssl, SSL_verify_mode => 0),
32 'new connection with reconnect enabled');
33 isscip-perl cpan Redis-Fast 0.37 main/is().($r->getscip-perl cpan Redis-Fast 0.37 Redis/Fast/get().('on_connect'), 3, '... on_connect code one again perfect');
34
35 $r->quitscip-perl cpan Redis-Fast 0.37 Redis/Fast/quit().;
36 isscip-perl cpan Redis-Fast 0.37 main/is().($r->getscip-perl cpan Redis-Fast 0.37 Redis/Fast/get().('on_connect'), 4, '... on_connect code works after reconnect also');
37 };
38
39
40 done_testingscip-perl cpan Redis-Fast 0.37 main/done_testing().();