summaryrefslogtreecommitdiff
path: root/t/05_object_siblings.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/05_object_siblings.t
parentMerge remote branch 'simon/fix_link_encoding' (diff)
downloadnet-riak-79bea382fd2c0753ca9ace79a11bb74c9a1d722b.tar.gz
merged pbc branch to master
Diffstat (limited to 't/05_object_siblings.t')
-rw-r--r--t/05_object_siblings.t47
1 files changed, 47 insertions, 0 deletions
diff --git a/t/05_object_siblings.t b/t/05_object_siblings.t
new file mode 100644
index 0000000..4bdec63
--- /dev/null
+++ b/t/05_object_siblings.t
@@ -0,0 +1,47 @@
+use lib 't/lib';
+use Test::More;
+use Test::Riak;
+
+test_riak {
+ my ($client, $bucket_name, $proto) = @_;
+
+ my $bucket = $client->bucket($bucket_name);
+ $bucket->allow_multiples(1);
+ ok $bucket->allow_multiples, 'multiples set to 1';
+
+ {
+ # test bucket still has multiples sep li
+ my $client = new_riak_client($proto);
+ my $bucket = $client->bucket($bucket_name);
+ ok $bucket->allow_multiples, 'bucket multiples set to 1';
+ }
+
+ {
+ my $obj = $bucket->get('foo');
+ is $obj->has_siblings, 0, 'has no sibilings';
+ is $obj->count_siblings, 0, 'has no sibilings';
+ }
+
+ for(1..5) {
+ my $client = new_riak_client($proto);
+ my $bucket = $client->bucket($bucket_name);
+ my $obj = $bucket->new_object('foo', [$_]);
+ $obj->store;
+ $obj->load;
+ }
+
+ my $obj = $bucket->get('foo');
+ ok $obj->has_siblings, 'object has siblings';
+ is $obj->count_siblings, 5, 'got 5 siblings';
+
+ my @siblings = $obj->siblings;
+ my $obj3 = $obj->sibling(3);
+
+ is_deeply $obj3->data, $obj->sibling(3)->data, 'sibling data matches';
+ $obj3 = $obj->sibling(3);
+ $obj3->store;
+ $obj->load;
+
+ is_deeply $obj->data, $obj3->data, 'sibling data still matches';
+ $obj->delete;
+}