| Revision 787337,
900 bytes
checked in by Tomash Brechko <tomash.brechko@…>, 4 years ago
(diff) |
|
Add t/noreply.t.
|
-
Property mode set to
100644
|
| Line | |
|---|
| 1 | use warnings; |
|---|
| 2 | use strict; |
|---|
| 3 | |
|---|
| 4 | use Test::More; |
|---|
| 5 | |
|---|
| 6 | use FindBin; |
|---|
| 7 | |
|---|
| 8 | use lib "$FindBin::Bin"; |
|---|
| 9 | use Memd; |
|---|
| 10 | |
|---|
| 11 | if ($Memd::memd) { |
|---|
| 12 | if ($Memd::version_num >= 10205) { |
|---|
| 13 | plan tests => 3; |
|---|
| 14 | } else { |
|---|
| 15 | plan skip_all => 'memcached 1.2.5 is required for noreply mode'; |
|---|
| 16 | } |
|---|
| 17 | } else { |
|---|
| 18 | plan skip_all => 'Not connected'; |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | use constant count => 100; |
|---|
| 23 | |
|---|
| 24 | my %params = %Memd::params; |
|---|
| 25 | foreach my $h (@{$params{servers}}) { |
|---|
| 26 | $h->{noreply} = 1 if ref($h) eq 'HASH'; |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | my $another_memd = new Cache::Memcached::Fast(\%params); |
|---|
| 30 | |
|---|
| 31 | my @keys = map { "noreply-$_" } (1..count); |
|---|
| 32 | |
|---|
| 33 | $another_memd->set_multi(map { [$_, $_] } @keys); |
|---|
| 34 | my $res = $another_memd->get_multi(@keys); |
|---|
| 35 | isa_ok($res, 'HASH'); |
|---|
| 36 | is(scalar keys %$res, scalar @keys, 'Number of entries in result'); |
|---|
| 37 | my $count = 0; |
|---|
| 38 | foreach my $k (@keys) { |
|---|
| 39 | ++$count if exists $res->{$k} and $res->{$k} eq $k; |
|---|
| 40 | } |
|---|
| 41 | is($count, count); |
|---|
| 42 | |
|---|
| 43 | $another_memd->delete_multi(@keys); |
|---|
Note: See
TracBrowser
for help on using the repository browser.