summaryrefslogtreecommitdiff
path: root/t/06_links.t
diff options
context:
space:
mode:
authorRobin Edwards <robin.ge@gmail.com>2011-04-20 14:38:43 +0100
committerRobin Edwards <robin.ge@gmail.com>2011-04-20 14:38:43 +0100
commit79bea382fd2c0753ca9ace79a11bb74c9a1d722b (patch)
treebde42a47792a27e0a863ee527b88c8c24258f7e9 /t/06_links.t
parentMerge remote branch 'simon/fix_link_encoding' (diff)
downloadnet-riak-79bea382fd2c0753ca9ace79a11bb74c9a1d722b.tar.gz
merged pbc branch to master
Diffstat (limited to 't/06_links.t')
-rw-r--r--t/06_links.t40
1 files changed, 40 insertions, 0 deletions
diff --git a/t/06_links.t b/t/06_links.t
new file mode 100644
index 0000000..d5effb0
--- /dev/null
+++ b/t/06_links.t
@@ -0,0 +1,40 @@
+use lib 't/lib';
+use Test::More;
+use Test::Riak;
+
+# store and get links
+test_riak {
+ my ($client, $bucket_name) = @_;
+
+ my $bucket = $client->bucket($bucket_name);
+ my $obj = $bucket->new_object("foo", [2]);
+ my $obj1 = $bucket->new_object("foo1", {test => 1})->store;
+ my $obj2 = $bucket->new_object("foo2", {test => 2})->store;
+ my $obj3 = $bucket->new_object("foo3", {test => 3})->store;
+ $obj->add_link($obj1);
+ $obj->add_link($obj2, "tag");
+ $obj->add_link($obj3, "tag2!@&");
+ $obj->store;
+ $obj = $bucket->get("foo");
+ is $obj->has_links, 3, 'got 3 links';
+};
+
+# link walking
+test_riak {
+ my ($client, $bucket_name) = @_;
+
+ my $bucket = $client->bucket($bucket_name);
+ my $obj = $bucket->new_object("foo", [2]);
+ my $obj1 = $bucket->new_object("foo1", {test => 1})->store;
+ my $obj2 = $bucket->new_object("foo2", {test => 2})->store;
+ my $obj3 = $bucket->new_object("foo3", {test => 3})->store;
+ $obj->add_link($obj1)->add_link($obj2, "tag")->add_link($obj3, "tag2!@&");
+ $obj->store;
+ $obj = $bucket->get("foo");
+ my $results = $obj->link($bucket_name)->run();
+ is scalar @$results, 3, 'got 3 links via links walking';
+ $results = $obj->link($bucket_name, 'tag')->run;
+ is scalar @$results, 1, 'got one link via link walking';
+};
+
+