Set up testing

Is there any documentation on actually setting up testing? I want to test my resource before I begin trying to implement my ui, but I can't find how to create or run migrations for the "test" postgres db. I'm new to elixir and phoenix in general so any direction on where to go to find this information would be appreciated. My current test looks like
defmodule OpenBudget.BudgetTest do
use OpenBudget.DataCase, async: true
require Ash.Query

test "can create budget" do
user =
OpenBudget.Accounts.User
|> Ash.Changeset.for_create(:register_with_password, %{
hashed_password: "password",
password: "password",
password_confirmation: "password"
})
|> OpenBudget.Accounts.create!()

assert user.email == "[email protected]"
end
end
defmodule OpenBudget.BudgetTest do
use OpenBudget.DataCase, async: true
require Ash.Query

test "can create budget" do
user =
OpenBudget.Accounts.User
|> Ash.Changeset.for_create(:register_with_password, %{
hashed_password: "password",
password: "password",
password_confirmation: "password"
})
|> OpenBudget.Accounts.create!()

assert user.email == "[email protected]"
end
end
The error I get is in the image attached. This error leads me to believe I need to run migrations for my open_budget_test database but running mix ash_postgres.migrate open_budget_test doesn't seem to do the trick. Thanks again for any guidance.
No description
4 Replies
ZachDaniel
ZachDaniel•3y ago
you'll need to run migration sin the test env MIX_ENV=test mix ash_postgres.migrate
lifeofdan
lifeofdanOP•3y ago
Thank you, that is exactly what I needed. Where should I have looked for this information, is this a basic elixir thing, a phoenix thing, or what. I don't want to waste anyone's time with my newbie questions.
ZachDaniel
ZachDaniel•3y ago
Well, its only kind of a basic elixir thing (the mix env part), but its tough because in Ash we wrap a library called Ecto and so a lot of people are familiar with those conventions and so we don't document them well. This one probably should have been in our docs 🙂
lifeofdan
lifeofdanOP•3y ago
Yeah, I'm sure I would not document it either if I was creating a library for a language I was familiar with. 🙂 Thank you very much for your help and kindness in your response. 🙂

Did you find this page helpful?