summaryrefslogtreecommitdiff
path: root/t/90_bug_links.t
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-08-10 10:18:51 +0200
committerfranck cuny <franck@lumberjaph.net>2010-08-10 10:18:51 +0200
commit75293a7491c6d6138f9c93118147dfbad285ad4b (patch)
treecf94648bc249e3ae45dba024a8f82598fdf91b9c /t/90_bug_links.t
parenttest for links (diff)
downloadnet-riak-75293a7491c6d6138f9c93118147dfbad285ad4b.tar.gz
more test, fix bug in links (thanks to Al Tobey)
Diffstat (limited to 't/90_bug_links.t')
-rw-r--r--t/90_bug_links.t24
1 files changed, 13 insertions, 11 deletions
diff --git a/t/90_bug_links.t b/t/90_bug_links.t
index d2b611a..32b30f0 100644
--- a/t/90_bug_links.t
+++ b/t/90_bug_links.t
@@ -1,10 +1,12 @@
use Data::Dumper;
use Net::Riak;
+use Test::More tests => 9;
-my $client = Net::Riak->new(host => 'http://127.0.0.1:8098');
+ok my $client = Net::Riak->new(host => 'http://127.0.0.1:8098'), 'client created';
# 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',
@@ -15,8 +17,9 @@ my $ref2 = {
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);
+
+ok $bucket_one->new_object( $ref1->{username} => $ref1 )->store(1,1), 'new object stored';
+ok $bucket_one->new_object( $ref2->{username} => $ref2 )->store(1,1), 'new object stored';
# create another bucket to store some data that will link to users
my $bucket_two = $client->bucket('TWO');
@@ -27,7 +30,7 @@ my $item_data = {
some_text => 'e86d62c91139f328df5f05e9698a248f',
epoch => time()
};
-my $item = $bucket_two->new_object( '25FCBA57-8D75-41B6-9E5A-0E2528BB3342' => $item_data );
+ok my $item = $bucket_two->new_object( '25FCBA57-8D75-41B6-9E5A-0E2528BB3342' => $item_data ), 'store new object to second bucket';
# create a link to each person that is stored in bucket 'ONE' and associate the link
# with the $item object
@@ -37,14 +40,13 @@ foreach my $person ( $ref1, $ref2 ) {
key => $person->{username},
tag => 'owners'
);
- $item->add_link( $link );
+ ok $item->add_link( $link ), 'link added to object';
}
# store to Riak
-$item->store( 1, 1 );
-
-# This shows the two links associated with the object
-print Dumper( $item );
+ok $item->store( 1, 1 ), 'object stored';
-# this does not show the links
-print Dumper( $bucket_two->get('25FCBA57-8D75-41B6-9E5A-0E2528BB3342', [1]) ) ;
+my $test_links = $bucket_two->get('25FCBA57-8D75-41B6-9E5A-0E2528BB3342', [1]);
+my $links = $test_links->links;
+is $links->[0]->key, 'griffinp', 'good owner for first link';
+is $links->[1]->key, 'griffins', 'good owner for second link';