Commits

Anonymous committed 351a474 Merge

merge

  • Participants
  • Parent commits 402bbfe, efa10a4

Comments (0)

Files changed (2)

src/jiak_util.erl

     ?assertEqual([<<"test">>], Mod:write_mask()),
     riak_ring_manager:stop(),
     riak_eventer:stop().
-    
-    
 
-bucket_from_uri_test() ->
+existing_bucket_from_uri_test() ->
     foo, %% make sure the atom exists
     PI = dict:store(bucket, "foo", dict:new()),
     RD0 = wrq:create('PUT', "1.1", "/jiak/foo", mochiweb_headers:empty()),
     RD = wrq:load_dispatch_data(PI, none, none, none, none, RD0),
-    {ok, foo} = bucket_from_uri(RD).
+    ?assertEqual({ok, foo}, bucket_from_uri(RD)).
+
+nonexisiting_bucket_from_uri_test() ->
+    PI = dict:store(bucket, "thisatomshouldntexistever", dict:new()),
+    RD0 = wrq:create('PUT', "1.1", "/jiak/foo", mochiweb_headers:empty()),
+    RD = wrq:load_dispatch_data(PI, none, none, none, none, RD0),    
+    ?assertEqual({error, no_such_bucket}, bucket_from_uri(RD)).
     

src/riak_mapreduce.erl

 reduce_plist_sum_test() ->
     PLs = [[{a, 1}], [{a, 2}],
            [{b, 1}], [{b, 4}]],
-    [{a,3},{b,5}] = reduce_plist_sum(PLs, test).
+    [{a,3},{b,5}] = reduce_plist_sum(PLs, test),
+    [{a,3},{b,5}] = reduce_plist_sum(lists:flatten(PLs), test),
+    [] = reduce_plist_sum([], test).
 
+map_spec_form_test_() ->
+    lists:append(
+      [ [?_assertMatch({map, {modfun, riak_mapreduce, F}, _, true},
+                       riak_mapreduce:F(true)),
+         ?_assertMatch({map, {modfun, riak_mapreduce, F}, _, false},
+                       riak_mapreduce:F(false))]
+        || F <- [map_identity, map_object_value, map_object_value_list] ]).
 
-
+reduce_spec_form_test_() ->
+    lists:append(
+      [ [?_assertMatch({reduce, {modfun, riak_mapreduce, F}, _, true},
+                       riak_mapreduce:F(true)),
+         ?_assertMatch({reduce, {modfun, riak_mapreduce, F}, _, false},
+                       riak_mapreduce:F(false))]
+        || F <- [reduce_set_union, reduce_sum, reduce_plist_sum] ]).