Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run remote function inside Unit test

im trying to setup some unit tests with Elixir but running into this error below. What am I doing wrong?

cannot invoke remote function PropertyManager.Database.get/0 inside match

Here is my code:

property_manager_test.exs

defmodule PropertyManagerTest do
  use ExUnit.Case

  test "the truth" do
    assert 1 + 1 == 2
  end

  test "get value from db" do
    assert PropertyManager.Database.get() = "test this"
  end

end

database.ex

defmodule PropertyManager.Database do

  def get do
    "test this"
  end

end
like image 933
Coldstar Avatar asked Dec 18 '14 20:12

Coldstar


Video Answer


1 Answers

Try with == instead of =

What you're doing in your code is a pattern match, which means it will try to match the right side to the pattern on the left side. A pattern can't contain function calls, which is probably the cause of your error.

like image 155
sasajuric Avatar answered Oct 10 '22 14:10

sasajuric