Is it possible to mute (mock?) Ecto.UUID.generate in an ExUnit test?

I use Ecto.UUID.generateto create a random token in the user model.

In my ExUnit test , I want to check the controller that calls the creation route, however, since the token is always random, I cannot deterministically check the result.

Ideally, I want to be able to stub Ecto.UUID.generatein my test so that it always generates the same UUID so that I can verify the answer correctly.

Thank:)

+4
source share
1 answer

Elixir Erlang , . , : http://blog.29steps.co.uk/post/105715556278/testing-api-web-calls-in-elixir-using-meck

, . API, , - UUID ( , Ecto.UUID.dump(uuid) {:ok, something}). browser/html, , UUID .

+4

All Articles