Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elixir support? #127

Open
brbrr opened this issue Nov 16, 2016 · 6 comments
Open

Elixir support? #127

brbrr opened this issue Nov 16, 2016 · 6 comments

Comments

@brbrr
Copy link

brbrr commented Nov 16, 2016

Hi,
Im new to erlang and elixir, so sorry for (maybe) obvious question.

Is it possible to use Escalus on elixir project? Im planning to write some tests for custom functionality in MongooseIM, but I prefer Elixir over Erlang because of the ruby like syntax etc.

Im kinda stuck on getting config file:

:application.set_env :escalus, :config_file, "test/test.config"
:escalus.create_users(:alice)
** (MatchError) no match of right hand side value: {:error, :enoent}

Escalus will look in to wrong dir(I insert erlang:display(Path) in to escalus_ct.erl:50):
/Users/brbrr/Development/Vega/eliTests/_build/test/lib/escalus/test/test.config instead of /Users/brbrr/Development/Vega/eliTests/test/test.config

@michalwski
Copy link
Contributor

Hi @brbrr,

Did you have a chance to read this [1] part of README file? Hope the information there will help you.

[1]. https://github.com/esl/escalus#escalus-as-a-standalone-application

@brbrr
Copy link
Author

brbrr commented Nov 21, 2016

ok, thanks! I'll try to use it. btw, is it correct place to ask questions?
So if im not using Common test, how can I pass config in to escalus? I need to define custom user_db module: {escalus_user_db, {module, custom_users, []}}.

@michalwski
Copy link
Contributor

This is the right place to ask questions.

You can use function escalus_users:create_users/2 https://github.com/esl/escalus/blob/master/src/escalus_users.erl#L89. The first arg is list of opts where you can put your custom module for creating users.

Getting back to your initial problem. You basically would like to add a new test suite but write it in Elixir instead of Erlang?

@brbrr
Copy link
Author

brbrr commented Nov 21, 2016

Yeah, I wanted to use Elixir to write some tests for custom mongoose server(custom registration, message delivery etc). I was thinking about Elixir just because im new for both elixir and erlang, and elixir looks kinda easier to get in to. But if I want to use custom modules - I need to use erlang...

So I started to use erlang, and make gears to spin a little, but now Im stuck on other problem.
My registration process is OTP based, so password comes from server. I need to store these passwords, and update/modify CT config somehow for further use in story function. but im not sure how to do this.

@michalwski
Copy link
Contributor

So I started to use erlang, and make gears to spin a little, but now Im stuck on other problem.
My registration process is OTP based, so password comes from server. I need to store these passwords, and update/modify CT config somehow for further use in story function. but im not sure how to do this.

I think ets [1] will help you here. Just create an public, named ets table. Store the password there and read it later when you need.

[1]. http://erlang.org/doc/man/ets.html

@brbrr
Copy link
Author

brbrr commented Nov 23, 2016

UPD: ah, its because init_per_group uses different process than test cases itself. was managed to workaround with: http://stackoverflow.com/a/15634582/3078381

Thanks! ets is working, but only when I use it inside same test case.

This will work:

messages_story_test(Config) ->
    escalus:create_users(Config), % inside my #create_user inserting passwords
    erlang:display(ets:tab2list(passwords)),
    escalus:story(Config, [{alice, 1}, {bob, 1}], fun(Alice, Bob) ->
......
end).

This wont:

init_per_group(_GroupName, Config) ->
    escalus:create_users(Config).

messages_story_test(Config) ->
    erlang:display(ets:tab2list(passwords)),
    escalus:story(Config, [{alice, 1}, {bob, 1}], fun(Alice, Bob) ->
    ......
end).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants