Anonymous avatar Anonymous committed 3e22614

test jiak_object:from_riak_object in the case of siblings

Comments (0)

Files changed (2)

src/jiak_object.erl

     ?assert(lists:member(hd(jiak_object:links(OldObj, remove_me)),
                          RemovedLinks)),
     ?assertEqual(1, length(RemovedLinks)).
+
+sibling_test() ->
+    %% don't need to do any interesting merges here - tests
+    %% for that are in jiak:standard_sibling_merge_test/0,
+    %% just need to make sure that the sibling merge branch
+    %% gets called
+    J0 = jiak_object:new(fake, <<"fake">>,
+                         {struct, [{<<"a">>, 1}]},
+                         [[a,<<"a">>,<<"a">>]]),
+    J1 = jiak_object:new(fake, <<"fake">>,
+                         {struct, [{<<"b">>, 2}]},
+                         [[b,<<"b">>,<<"b">>]]),
+    [{M0,V0}] = riak_object:get_contents(to_riak_object(J0)),
+    [{M1,V1}] = riak_object:get_contents(to_riak_object(J1)),
+    M0p = dict:store(<<"X-Riak-Last-Modified">>,
+                     httpd_util:rfc1123_date(),
+                     dict:store(<<"X-Riak-VTag">>, "hello", M0)),
+    M1p = dict:store(<<"X-Riak-Last-Modified">>,
+                     httpd_util:rfc1123_date(),
+                     dict:store(<<"X-Riak-VTag">>, "goodbye", M1)),
+    
+    R = riak_object:increment_vclock(
+          riak_object:set_contents(
+            riak_object:new(jiak_example, <<"fake">>, ignore),
+            [{M0p,V0},{M1p,V1}]),
+          <<"tester">>),
+
+    J = from_riak_object(R),
+
+    ?assertEqual(getp(J0, <<"a">>), getp(J, <<"a">>)),
+    ?assertEqual(getp(J1, <<"b">>), getp(J, <<"b">>)),
+    ?assertEqual(2, length(props(J))),
+    
+    ?assertEqual(links(J0, a), links(J, a)),
+    ?assertEqual(links(J1, b), links(J, b)),
+    ?assertEqual(2, length(links(J))).

src/jiak_util.erl

                 undefined -> undefined;
                 Mod when is_tuple(Mod) -> Mod
             end;
-        ModPath when is_list(ModPath) -> Bucket
+        ModPath when is_list(ModPath) -> Bucket;
+        cover_compiled -> Bucket %% used during eunit testing
     end.
 
 %% @spec bucket_from_uri(webmachine:wrq()) ->
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.