ecto_mnesia icon indicating copy to clipboard operation
ecto_mnesia copied to clipboard

Record does not get deleted in on_exit callback

Open aus70 opened this issue 7 years ago • 2 comments

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 mixand 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!

aus70 avatar Sep 29 '17 00:09 aus70

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.

AndrewDryga avatar Oct 03 '17 19:10 AndrewDryga

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.

aus70 avatar Oct 06 '17 14:10 aus70