Skip to content

Commit

Permalink
Support fresh story_with_config
Browse files Browse the repository at this point in the history
  • Loading branch information
pzel committed Mar 9, 2016
1 parent 3e48877 commit b47159c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
3 changes: 1 addition & 2 deletions include/escalus.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@
compress :: {zlib, {Zin::zlib:zstream(), Zout::zlib:zstream()}}
| false,
rcv_pid :: pid(),
event_client :: any(),
user_spec = [] :: proplists:proplist()
event_client :: any()
}).
2 changes: 2 additions & 0 deletions src/escalus.erl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
override/3,
make_everyone_friends/1,
fresh_story/3,
fresh_story_with_config/3,
story/3,
assert/2,
assert/3,
Expand Down Expand Up @@ -98,6 +99,7 @@ end_per_testcase(_CaseName, Config) ->
?FORWARD3(escalus_story, story).

?FORWARD3_AS(escalus_fresh, story, fresh_story).
?FORWARD3_AS(escalus_fresh, story_with_config, fresh_story_with_config).

?FORWARD2(escalus_new_assert, assert).
?FORWARD3(escalus_new_assert, assert).
Expand Down
8 changes: 2 additions & 6 deletions src/escalus_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
short_jid/1,
username/1,
server/1,
resource/1,
spec/1
resource/1
]).

-import(escalus_compat, [bin/1, unimplemented/0]).
Expand All @@ -54,7 +53,7 @@ start(Config, UserSpec, Resource) ->
case escalus_connection:start(Options) of
{ok, Conn, Props, _} ->
Jid = make_jid(Props),
Client = Conn#client{jid = Jid, event_client = EventClient, user_spec = UserSpec},
Client = Conn#client{jid = Jid, event_client = EventClient},
escalus_cleaner:add_client(Config, Client),
{ok, Client};
{error, Error} ->
Expand Down Expand Up @@ -146,9 +145,6 @@ server(Client) ->
resource(Client) ->
escalus_utils:regexp_get(full_jid(Client), <<"^[^/]*[/](.*)">>).

spec(#client{user_spec = US}) ->
US.

%%--------------------------------------------------------------------
%% helpers
%%--------------------------------------------------------------------
Expand Down
10 changes: 9 additions & 1 deletion src/escalus_fresh.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
-module(escalus_fresh).
-export([story/3]).
-export([story/3, story_with_config/3]).

story_with_config(Config, UserSpecs, StoryFun) ->
FreshSpecs = fresh_specs(Config, UserSpecs, fresh_suffix()),
case length(FreshSpecs) == length(UserSpecs) of
false -> ct:fail("failed to get required users"); _ -> ok end,
FreshConfig = escalus_users:create_users(Config, FreshSpecs),
escalus:story(FreshConfig, UserSpecs,
fun(Args) -> apply(StoryFun, [FreshConfig|Args]) end).

story(Config, UserSpecs, StoryFun) ->
FreshSpecs = fresh_specs(Config, UserSpecs, fresh_suffix()),
Expand Down

0 comments on commit b47159c

Please sign in to comment.