Skip to content

Commit

Permalink
Expect config list to return from delete_users
Browse files Browse the repository at this point in the history
  • Loading branch information
pzel committed Mar 17, 2016
1 parent b4621f5 commit 944adcc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/escalus_fresh.erl
Expand Up @@ -51,7 +51,9 @@ create_users(Config, UserSpecs) ->
start(_Config) -> ensure_table_present(nasty_global_table()).
stop(_) -> nasty_global_table() ! bye.
clean() ->
[ok|_] = pmap(fun delete_users/1, ets:tab2list(nasty_global_table())),
true = lists:all(fun(A) -> A == ok end,
pmap(fun delete_users/1,
ets:tab2list(nasty_global_table()))),
ets:delete_all_objects(nasty_global_table()),
ok.

Expand All @@ -60,7 +62,7 @@ nasty_global_table() -> escalus_fresh_db.

delete_users({_Suffix, Conf}) ->
Plist = proplists:get_value(escalus_users, Conf),
{ok, _} = escalus_users:delete_users(Conf, Plist),
escalus_users:delete_users(Conf, Plist),
ok.

ensure_table_present(T) ->
Expand Down Expand Up @@ -103,7 +105,7 @@ pmap(F, L) when is_function(F, 1), is_list(L) ->
tag(L) -> lists:zip(lists:seq(1, length(L)), L).
untag(L) -> [ Val || {_Ord, Val} <- lists:sort(L) ].
reply(Ord, {Ref, Pid}, Val) -> Pid ! {Ref, {Ord, Val}}.
worker(TaskId, Fun, {Ord, Item}) -> fun() -> reply(Ord, TaskId, Fun(Item)) end.
worker(TaskId, Fun, {Ord, Item}) -> fun() -> reply(Ord, TaskId, catch(Fun(Item))) end.
collect(_TaskId, 0, Acc) -> untag(Acc);
collect({Ref, _} = TaskId, N, Acc) ->
receive {Ref, Val} -> collect(TaskId, N-1, [Val|Acc])
Expand Down
2 changes: 1 addition & 1 deletion test/escalus_fresh_SUITE.erl
Expand Up @@ -78,4 +78,4 @@ internal_fresh_db() -> escalus_fresh_db.
start(C) -> C.
stop(C) -> C.
create_users(C, Specs) -> lists:keystore(escalus_users, 1, C, {escalus_users, Specs}).
delete_users(_C, _) -> {ok, deleted}.
delete_users(C, _) -> C.

0 comments on commit 944adcc

Please sign in to comment.