summaryrefslogtreecommitdiff
path: root/xt
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
parentupdate tests (diff)
downloadanyevent-riak-e71ee6fc097b832df6808a4a97f89029d971e196.tar.gz
switch to dzil; rename tests; update changelog
Diffstat (limited to 'xt')
-rw-r--r--xt/00_sync.t39
-rw-r--r--xt/01_async.t150
2 files changed, 189 insertions, 0 deletions
diff --git a/xt/00_sync.t b/xt/00_sync.t
new file mode 100644
index 0000000..a8cf910
--- /dev/null
+++ b/xt/00_sync.t
@@ -0,0 +1,39 @@
+use strict;
+use warnings;
+
+use JSON;
+use Test::More;
+use AnyEvent::Riak;
+
+#plan tests => 4;
+
+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';
+
+ok my $ping = $riak->is_alive()->recv, 'ping: host is alive';
+ok my $buckets =
+ $riak->list_bucket('blog_content_temp', {keys => 'false'})->recv,
+ "fetch bucket list";
+
+my $value = {foo => 1};
+
+ok my ($res, $headers) = $riak->store('foo', $value)->recv,
+ 'set a new key';
+($res, $headers) = $riak->store('foo', $value, {key => 'foo_test'})->recv;
+ok $res, 'stored key foo_test';
+
+ok $res = $riak->fetch('foo', 'foo_test')->recv, 'fetch our new key';
+
+is_deeply $value, $res, 'got same data';
+
+ok $res = $riak->delete( 'foo', 'foo_test' )->recv, 'delete our key';
+
+done_testing;
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();