Skip to content

Instantly share code, notes, and snippets.

@zkessin
Created July 5, 2017 13:00
Show Gist options
  • Save zkessin/1b2b435e9589fe1ad5ccc9674cdbcc7f to your computer and use it in GitHub Desktop.
Save zkessin/1b2b435e9589fe1ad5ccc9674cdbcc7f to your computer and use it in GitHub Desktop.
-module(barrel_rpc_eqc).
-compile(export_all).
-include_lib("eqc/include/eqc.hrl").
-include_lib("eunit/include/eunit.hrl").
-define(DB, <<"testdb">>).
init_db()->
barrel:create_db(#{ <<"database_id">> => <<"testdb">> }),
fun delete_db/0.
delete_db() ->
ok = barrel:delete_db(<<"testdb">>),
ok.
prop_rpc_crud() ->
?SETUP(fun init_db/0,
?FORALL({Id,Doc},
{non_empty(utf8()),
non_empty(map(non_empty(utf8()), non_empty(utf8())))},
begin
Doc1 = maps:put(<<"id">>, Id, Doc),
{ok, Id,_r} = barrel:post(?DB, Doc1, []),
{ok, Doc1,_} = barrel:get(?DB, Id, []),
{ok, _,_} = barrel:delete(?DB, Id, []),
true
end)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment