D4no0

D4no0

Mox strange race conditions

I seem to be getting some strange undefined behavior when defining multiple separated mocks for the same module in the same test:

  HttpClientMock
  |> expect(:request, fn request -> build_response() end)
  |> allow(self(), fn -> Process.whereis(MyProcess) end)

# Later in that same test

  HttpClientMock
  |> expect(:request, fn request -> build_another_response() end)
  |> allow(self(), fn -> Process.whereis(MyNewProcess) end)

Is this a limitation that Mox has? I’ve read already the documentation a few times and I couldn’t find any things specified about this, it is completely unclear what happens under the hood as it seems these definitions are doing only side-effects.

Marked As Solved

mudasobwa

mudasobwa

Creator of Cure

Note for the future readers: there was a bug with multiple lazy defined allowances until v1.2.0 which I fixed.

Also Liked

D4no0

D4no0

I am not sure how I can show an example, what I have are multiple genservers (some of them dependent on each-other) hitting multiple HTTP APIs.

I can confirm that with version 1.1.0, even with the race condition fixed in my application code, the tests still fail randomly as before, I’ve actually upgraded the dependency right in the middle of writing this topic so I might have experienced that bug too before upgrading. I did not mention it, because I didn’t saw bugfixes mentioned in changelogs of the new version. Thanks for the fix!

mudasobwa

mudasobwa

Creator of Cure

Well, technically I brought this bug and then I fixed it.

The deferred allowance is my idea and my implementation, probably that is why it was buggy in the first place :slight_smile:

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
kostonstyle
Hi all I want to have a unix time, from the current time plus 1 hour. DateTime.now + 1 hour How to get it in elixir? Thanks
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement