Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate with in-memory db in test suites #187

Open
KoushikDasika opened this issue Jun 4, 2022 · 1 comment
Open

Integrate with in-memory db in test suites #187

KoushikDasika opened this issue Jun 4, 2022 · 1 comment

Comments

@KoushikDasika
Copy link

KoushikDasika commented Jun 4, 2022

The current challenge I am facing is that I want to write integration tests that add and remove data from the database and I miss the safety of the Ecto.SQL.Sandbox. I would like my test suite to spin up a local database (possibly per testfile), run its test, and then shut it down once the suite is complete. I find myself thinking about how i need to configure my CI (docker with one container? docker with multiple containers? native runner?)

In other ecosystems like NodeJS, there are adapters to the test suites that can spin up an ephemeral in-memory database just for the tests.

https://github.com/shelfio/jest-mongodb
https://github.com/nodkz/mongodb-memory-server

I can spin up a unique database per test file, I can configure a ReplSet for Multi-doc transactions, etc.

  1. Am I doing it wrong? Is there a better way that I haven't thought of for mongo_ecto?
  2. Is there interest in adding either this plugin or porting this functionality to an optional addon?
@scottmessinger
Copy link
Collaborator

H @KoushikDasika ! Great question. An memory option would be great, but I don't know how we'd do it.

For our app, we're using Github actions and use a github actions steps:

      - name: Start MongoDB
        uses: supercharge/[email protected]
        with:
          mongodb-version: 4.2
          mongodb-replica-set: "replica-set"

Let me know if that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants