ecto_mnesia
ecto_mnesia copied to clipboard
Record does not get deleted in on_exit callback
Within a ExUnit test, I use an on_exit
callback to cleanup the database after testing:
IO.inspect(My.Account |> My.Repo.all) # shows a record
My.Account
|> Ecto.Query.where(my_id: ^my_id)
|> My.Repo.delete_all
IO.inspect(My.Account |> My.Repo.all) # shows []
After testing, I run iex - S mix
and then My.Account |> My.Repo.all
, which still shows the same record. Is this result to be expected? Why doesn't the record get deleted? Am I missing anything?
My best guess is that the delete does not get synced to disk. If this is the case, is there an idiomatic way to force the sync?
Thanks!
Are you sure that this is exactly the same account? It could bethat you have different mnesia paths for iex and test environments, so you see two different databases.
Yes, it was. I have now a path for each environment (dev, test, production) and I wipe all tables before the tests. I couldn't solve the original problem, but now I can live with it.