diff options
author | franck cuny <franck@lumberjaph.net> | 2010-05-11 11:18:03 +0200 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2010-05-11 11:18:03 +0200 |
commit | 7646980f2f407e73f4035a6d98c387ab7e6193e0 (patch) | |
tree | c52f569a112b6329054fc08b843d0e9cdea05aa9 | |
parent | separate tests (diff) | |
download | anyevent-riak-7646980f2f407e73f4035a6d98c387ab7e6193e0.tar.gz |
update tests
-rw-r--r-- | t/10_async.t | 101 |
1 files changed, 56 insertions, 45 deletions
diff --git a/t/10_async.t b/t/10_async.t index 06e1f1a..9e88280 100644 --- a/t/10_async.t +++ b/t/10_async.t @@ -7,7 +7,7 @@ use Test::Exception; use AnyEvent::Riak; use YAML::Syck; -#plan tests => 15; +plan tests => 5; my ( $host, $path ); @@ -18,8 +18,6 @@ BEGIN { unless ($host && $path); } - - my $bucket = 'test'; ok my $riak = AnyEvent::Riak->new( @@ -30,48 +28,61 @@ ok my $riak = AnyEvent::Riak->new( ), 'create riak object'; -my $cv = AnyEvent->condvar; -$cv->begin(sub { $cv->send }); -$cv->begin; - -# ping -$riak->is_alive( - callback => sub { - my $res = shift; - pass "is alive in cb" if $res; - } -); - -# list bucket -$riak->list_bucket( - 'bar', - parameters => {props => 'true', keys => 'true'}, - callback => sub { - my $res = shift; - ok $res->{props}, 'got props'; - is scalar @{$res->{keys}}, 0, '0 keys in cb'; - } -); - -my $value = {foo => 'bar',}; +{ + my $cv = AnyEvent->condvar; + $cv->begin(sub { $cv->send }); + $cv->begin; + # ping + $riak->is_alive( + callback => sub { + my $res = shift; + pass "is alive in cb" if $res; + $cv->end; + } + ); + $cv->end; + $cv->recv; +} -# store object -$riak->store( - 'foo', 'bar3', $value, - callback => sub { - pass "store value ok"; - $riak->fetch( - 'foo', 'bar3', - callback => sub { - my $body = shift; - is_deeply($body, $value, 'value is ok in cb'); - $cv->end; - } - ); - } -); +{ + my $cv = AnyEvent->condvar; + $cv->begin(sub { $cv->send }); + $cv->begin; + # list bucket + $riak->list_bucket( + $bucket, + parameters => {props => 'true', keys => 'true'}, + callback => sub { + my $res = shift; + ok $res->{props}, 'got props'; + $cv->end; + } + ); + $cv->end; + $cv->recv; +} -$cv->end; -$cv->recv; +{ + my $value = {foo => 'bar',}; + my $cv = AnyEvent->condvar; + $cv->begin(sub { $cv->send }); + $cv->begin; -done_testing(); + # store object + $riak->store( + $bucket, 'bar3', $value, + callback => sub { + pass "store value ok"; + $riak->fetch( + 'foo', 'bar3', + callback => sub { + my $body = shift; + is_deeply($body, $value, 'value is ok in cb'); + $cv->end; + } + ); + } + ); + $cv->end; + $cv->recv; +} |