Postgrex.Notifications process doesn't receive notifications in tests

Tags: #<Tag:0x00007f1142a47d38> #<Tag:0x00007f1142a47338>


Or, at least, that’s what I think happens

I have a listener of NOTIFY messages from postgres, and even though in dev it works (see web readme), this test, which relies on the listener fails.


It sounds like your tests are using the SQL sandbox:

so the test would happen inside a transaction which gets rolled back at the end. Since the transaction is never committed, the NOTIFY is not emitted either. You could create a new case based on ChannelCase that doesn’t have the sandbox setup code, so that your test actually commits to DB.


Used Ecto.Adapters.SQL.Sandbox.unboxed_run/2, seems to work for now.

Thank you!


Do you manually clean up after that test? If you don’t it will leave lingering data right?


Didn’t think of that. Yes, all the posts created during these unboxed tests are still in the test database. Will add some clean up phase now, thank you!