So is there something i should know about database condition when testing?
Maybe that it happens inside a transaction and this transaction never gets committed. I think I had a similar problem recently, see Postgrex.Notifications process doesn't receive notifications in tests.
Try running your test inside Ecto.Adapters.SQL.Sandbox.unboxed_run/2
:
test "successfully add new review source", %{conn: conn} do
Ecto.Adapters.SQL.Sandbox.unboxed_run(YourApp.Repo, fn ->
conn = Accounts.sign_in_user(conn, user)
conn = post conn, review_source_path(conn, :create, review_source: %{
# ...
})
end)
# don't forget to clean up inserted data afterwards
end
This would actually commit the transaction, so your other service will see the inserted data.