summary refs log tree commit diff
path: root/xt/01_async.t
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-05-11 11:22:58 +0200
committerfranck cuny <franck@lumberjaph.net>2010-06-08 08:02:41 +0200
commite71ee6fc097b832df6808a4a97f89029d971e196 (patch)
tree65ce4819db1b2ddc104cd20c5d70e5d4136d3920 /xt/01_async.t
parentupdate tests (diff)
downloadanyevent-riak-e71ee6fc097b832df6808a4a97f89029d971e196.tar.gz
switch to dzil; rename tests; update changelog
Diffstat (limited to 'xt/01_async.t')
-rw-r--r--xt/01_async.t150
1 files changed, 150 insertions, 0 deletions
diff --git a/xt/01_async.t b/xt/01_async.t
new file mode 100644
index 0000000..a42f751
--- /dev/null
+++ b/xt/01_async.t
@@ -0,0 +1,150 @@
+use strict;
+use warnings;
+
+use Test::More;
+use JSON::XS;
+use Test::Exception;
+use AnyEvent::Riak;
+use YAML::Syck;
+
+#plan tests => 6;
+
+my $host = 'http://10.0.0.42:8098';
+my $path = 'riak';
+
+ok my $riak = AnyEvent::Riak->new(
+    host => $host,
+    path => $path,
+    w    => 1,
+    dw   => 1
+  ),
+  'create riak object';
+
+my $cv = AnyEvent->condvar;
+
+$riak->is_alive(
+    callback => sub {
+        my $res = shift;
+        ok $res, "is alive in cb";
+    }
+);
+
+$riak->list_bucket(
+    'blog_content_temp',
+    {keys => 'false'},
+    sub {
+        my $res = shift;
+        ok $res, "got result list_bucket";
+    }
+);
+
+$riak->set_bucket(
+    'blog_content_temp',
+    {n_val => 5},
+    sub {
+        my $res = shift;
+        ok $res, "got result in set_bucket"
+    }
+);
+
+$riak->fetch(
+    'blog_content_temp',
+    '012853de99ce67c2f0f09c0c2ea28cbe5de8f653137d273803f85a398d1de840',
+    sub {
+        my $res = shift;
+        ok $res, "got result in fetch"
+    }
+);
+
+$riak->store(
+    'blog_content_temp',
+    {foo => 1},
+    sub {
+        my $res = shift;
+        ok $res, "got result in store"
+    }
+);
+
+$cv->recv;
+
+# 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
+
+
+# }
+
+# # {
+# #     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;
+# # }
+
+# # {
+# #     my $key   = 'bar';
+# #     my $value = {foo => 'bar',};
+# #     my $cv    = AnyEvent->condvar;
+# #     $cv->begin(sub { $cv->send });
+# #     $cv->begin;
+
+# #     # store object
+# #     $riak->store(
+# #         $bucket, $key, $value,
+# #         callback => sub {
+# #             pass "store value ok";
+# #             $riak->fetch(
+# #                 $bucket, $key,
+# #                 callback => sub {
+# #                     my $body = shift;
+# #                     is_deeply($body, $value, 'value is ok in cb');
+# #                     $riak->delete(
+# #                         $bucket, $key,
+# #                         callback => sub {
+# #                             my $res = shift;
+# #                             is $res, 1, 'key deleted';
+# #                             $cv->end;
+# #                         }
+# #                     );
+
+# #                 }
+# #             );
+# #         }
+# #     );
+# #     $cv->end;
+# #     $cv->recv;
+# # }
+
+done_testing();