reconnect to redis if the connection went away
[perl-Redis.git] / t / 20-Redis-Hash.t
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use Test::More tests => 8;
7 use lib 'lib';
8
9 BEGIN {
10         use_ok( 'Redis::Hash' );
11 }
12
13 ok( my $o = tie( my %h, 'Redis::Hash', 'test-redis-hash' ), 'tie' );
14
15 isa_ok( $o, 'Redis::Hash' );
16
17 $o->CLEAR();
18
19 ok( ! keys %h, 'empty' );
20
21 my $commands_processed_before = $o->info->{total_commands_processed};
22
23 ok( %h = ( 'foo' => 42, 'bar' => 1, 'baz' => 99 ), '=' );
24
25 is_deeply( [ sort keys %h ], [ 'bar', 'baz', 'foo' ], 'keys' );
26
27 is_deeply( \%h, { bar => 1, baz => 99, foo => 42, }, 'structure' );
28
29 ok( $commands_processed_before < $o->info->{total_commands_processed}, 'more processed commands than before' );