summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-08-10 10:03:06 +0200
committerfranck cuny <franck@lumberjaph.net>2010-08-10 10:03:06 +0200
commit0366c8486539e65370d211c425767f566fb61b96 (patch)
treeba38cdcf7f8a029018c7ae8e0e66c16cb17a58e4
parentupdate (diff)
downloadnet-riak-0366c8486539e65370d211c425767f566fb61b96.tar.gz
test for links
-rw-r--r--t/90_bug_links.t50
1 files changed, 50 insertions, 0 deletions
diff --git a/t/90_bug_links.t b/t/90_bug_links.t
new file mode 100644
index 0000000..d2b611a
--- /dev/null
+++ b/t/90_bug_links.t
@@ -0,0 +1,50 @@
+use Data::Dumper;
+use Net::Riak;
+
+my $client = Net::Riak->new(host => 'http://127.0.0.1:8098');
+
+# set up a bucket containing two person/user records and store them
+my $bucket_one = $client->bucket('ONE');
+my $ref1 = {
+    username => 'griffinp',
+    fullname => 'Peter Griffin',
+    email => 'peter@familyguy.com'
+};
+my $ref2 = {
+    username => 'griffins',
+    fullname => 'Stewie Griffin',
+    email => 'stewie@familyguy.com'
+};
+$bucket_one->new_object( $ref1->{username} => $ref1 )->store(1,1);
+$bucket_one->new_object( $ref2->{username} => $ref2 )->store(1,1);
+
+# create another bucket to store some data that will link to users
+my $bucket_two = $client->bucket('TWO');
+
+# create the object
+my $item_data = {
+    a_number  => rand(),
+    some_text => 'e86d62c91139f328df5f05e9698a248f',
+    epoch     => time()
+};
+my $item = $bucket_two->new_object( '25FCBA57-8D75-41B6-9E5A-0E2528BB3342' => $item_data );
+
+# create a link to each person that is stored in bucket 'ONE' and associate the link
+# with the $item object
+foreach my $person ( $ref1, $ref2 ) {
+    my $link = Net::Riak::Link->new(
+        bucket => $bucket_one,
+        key    => $person->{username},
+        tag    => 'owners'
+    );
+    $item->add_link( $link );
+}
+
+# store to Riak
+$item->store( 1, 1 );
+
+# This shows the two links associated with the object
+print Dumper( $item );
+
+# this does not show the links
+print Dumper( $bucket_two->get('25FCBA57-8D75-41B6-9E5A-0E2528BB3342', [1]) ) ;