How to create Ecto temporary tables for test a library

I have recently been working on my CRUD macro, which uses Ecto and is prepared for Postgres.

My problem comes when I want to make some tests for my macro, but there are no tables like users schema, and I don’t need to keep it after my test even.

So I need a temporary tables creator and a table deleter after the test.

I found this post that suggested creating it as a pure PSQL command in Ecto function, Ecto.Adapters.SQL — Ecto SQL v3.7.1

Example test I created; as you see in this file, I had a schema and a Repo, then I was able to test it, but when I wanted to separate this and create a new library, I could not try it because I have no schema.

Thanks

2 Likes