samedi 7 avril 2018

How to debug no message matching on assert_receive

I have this test

defmodule InfoSys.Backends.WolframTest do
  use ExUnit.Case, async: true
  alias InfoSys.WolFram

  test "make request, report results, then terminates" do
    ref = make_ref()
    {:ok, pid} = WolFram.start_link("1 + 1", ref, self(), 1)

    assert_receive {:results, ^ref, [%InfoSys.Result{text: "2"}]}
  end
end

and I am receiving

No message matching {:results, ^ref, [%InfoSys.Result{text: "2"}]} after 100ms.

How can I know which message is ref receiving or how can I debug this error? I am following phoenix book programming example

Whole ExUnit stacktrace:

  1) test make request, report results, then terminates (InfoSys.Backends.WolframTest)
     test/backends/wolfram_test.exs:6
     No message matching {:results, ^ref, [%InfoSys.Result{text: "2"}]} after 100ms.
     The following variables were pinned:
       ref = #Reference<0.214527998.4009754625.219099>
     The process mailbox is empty.
     code: assert_receive {:results, ^ref, [%InfoSys.Result{text: "2"}]}
     stacktrace:
       test/backends/wolfram_test.exs:11: (test)

Aucun commentaire:

Enregistrer un commentaire