File: basic.t

package info (click to toggle)
libtest-redisserver-perl 0.21-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 188 kB
  • sloc: perl: 171; makefile: 11; sh: 4
file content (45 lines) | stat: -rw-r--r-- 1,107 bytes parent folder | download | duplicates (3)
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 warnings;
use Test::More 0.98;
use Test::TCP;

use Redis;
use Test::RedisServer;

eval { Test::RedisServer->new } or plan skip_all => 'redis-server is required in PATH to run this test';

# unix socket by default
my $server = Test::RedisServer->new;
ok $server->pid, 'pid ok';

my %connect_info = $server->connect_info;
like $connect_info{sock}, qr{/redis\.sock$}, 'unix socket ok';
ok !$connect_info{server}, 'server key does not exist ok';

my $redis = Redis->new(%connect_info);
is $redis->ping, 'PONG', 'ping pong ok';

$server->stop;
is $server->pid, undef, 'pid removed ok';
is $redis->ping, undef, 'no server available ok';

# port
my $port = empty_port();
$server = Test::RedisServer->new(conf => {
    bind => '127.0.0.1',
    port => $port,
});
ok $server->pid, 'pid ok';

%connect_info = $server->connect_info;
ok !$connect_info{sock}, 'sock does not exist ok';
is $connect_info{server}, '127.0.0.1:' . $port, 'server addr ok';

$redis = Redis->new(%connect_info);
is $redis->ping, 'PONG', 'ping pong ok';

undef $server;

is $redis->ping, undef, 'server died ok';

done_testing;