Ash FrameworkAF
Ash Framework3y ago
2 replies
Robert Graff

Testing with log_in_user

I'm writing tests and have a helper to log_in_user that I found in ash-hq source.

  def log_in_user(conn, user) do
    conn
    |> Phoenix.ConnTest.init_test_session(%{})
    |> Plug.Conn.put_session(:user_token, user.__metadata__.token)
  end


But user.__metadata__ == %{} which makes sense since I'm generating the user with Ash.Seed. In ash-hq the user is created by a register action which I assume sets the metadata, but don't see how. I don't have an equivalent register action.

How do I generate this token?
Was this page helpful?