Coldstar
Coldstar

Reputation: 1341

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

Upvotes: 10

Views: 1986

Answers (1)

sasajuric
sasajuric

Reputation: 6059

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.

Upvotes: 14

Related Questions