summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-05-11 11:02:06 +0200
committerfranck cuny <franck@lumberjaph.net>2010-05-11 11:02:06 +0200
commit9c67f361f66f3f9c3e9dc1b34b48bc7c2f02db7a (patch)
treee33d61479febe02910c2f885896e8d849662a5a2
parentremove client_id (diff)
downloadanyevent-riak-9c67f361f66f3f9c3e9dc1b34b48bc7c2f02db7a.tar.gz
separate tests
-rw-r--r--t/10_async.t77
1 files changed, 77 insertions, 0 deletions
diff --git a/t/10_async.t b/t/10_async.t
new file mode 100644
index 0000000..06e1f1a
--- /dev/null
+++ b/t/10_async.t
@@ -0,0 +1,77 @@
+use strict;
+use warnings;
+
+use Test::More;
+use JSON::XS;
+use Test::Exception;
+use AnyEvent::Riak;
+use YAML::Syck;
+
+#plan tests => 15;
+
+my ( $host, $path );
+
+BEGIN {
+    my $riak_test = $ENV{RIAK_TEST_SERVER};
+    ($host, $path) = split ";", $riak_test if $riak_test;
+    plan skip_all => 'set $ENV{RIAK_TEST_SERVER} if you want to run the tests'
+      unless ($host && $path);
+}
+
+
+
+my $bucket = 'test';
+
+ok my $riak = AnyEvent::Riak->new(
+    host => $host,
+    path => $path,
+    w    => 1,
+    dw   => 1
+  ),
+  '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',};
+
+# 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;
+            }
+        );
+    }
+);
+
+$cv->end;
+$cv->recv;
+
+done_testing();