From 79bea382fd2c0753ca9ace79a11bb74c9a1d722b Mon Sep 17 00:00:00 2001 From: Robin Edwards Date: Wed, 20 Apr 2011 14:38:43 +0100 Subject: merged pbc branch to master --- t/05_object_siblings.t | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 t/05_object_siblings.t (limited to 't/05_object_siblings.t') 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; +} -- cgit v1.2.3