Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test helper passes in a riak client to the fun

  • Loading branch information...
commit 3e936e7fb3dc7cc8e7fb0097ded3ff9726a86284 1 parent f0ef7b6
Cliff Moon authored
19 apps/luwak/test/luwak_obj_tests.erl
View
@@ -3,8 +3,7 @@
-include_lib("eunit/include/eunit.hrl").
object_creation_test() ->
- test_helper:riak_test(fun() ->
- {ok, Riak} = riak:local_client(),
+ test_helper:riak_test(fun(Riak) ->
Dict = dict:new(),
luwak_obj:create(Riak, <<"file1">>, dict:store(key, value, Dict)),
{ok, Obj} = luwak_obj:get(Riak, <<"file1">>),
@@ -13,12 +12,24 @@ object_creation_test() ->
end).
set_attributes_test() ->
- test_helper:riak_test(fun() ->
- {ok, Riak} = riak:local_client(),
+ test_helper:riak_test(fun(Riak) ->
Dict = dict:new(),
{ok, Obj} = luwak_obj:create(Riak, <<"file1">>, dict:store(key, value, Dict)),
{ok, Obj2} = luwak_obj:set_attributes(Riak, Obj, dict:store(key, blah, Dict)),
Attr = luwak_obj:get_attributes(Obj2),
?assertEqual({ok, blah}, dict:find(key, Attr))
end).
+
+exists_test() ->
+ test_helper:riak_test(fun(Riak) ->
+ {ok, Obj} = luwak_obj:create(Riak, <<"file1">>, dict:new()),
+ ?assertEqual({ok, true}, luwak_obj:exists(Riak, <<"file1">>))
+ end).
+
+delete_test() ->
+ test_helper:riak_test(fun(Riak) ->
+ {ok, Obj} = luwak_obj:create(Riak, <<"file1">>, dict:new()),
+ ok = luwak_obj:delete(Riak, <<"file1">>),
+ ?assertEqual({ok, false}, luwak_obj:exists(Riak, <<"file1">>))
+ end).
3  apps/luwak/test/test_helper.erl
View
@@ -4,7 +4,8 @@
riak_test(Fun) ->
start_riak(),
- Ret = (catch Fun()),
+ {ok, Riak} = riak:local_client(),
+ Ret = (catch Fun(Riak)),
stop_riak(),
case Ret of
{'EXIT', Err} -> throw(Err);
Please sign in to comment.
Something went wrong with that request. Please try again.