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

Question: Database sandbox for tests #123

Open
martinthenth opened this issue Apr 2, 2021 · 1 comment
Open

Question: Database sandbox for tests #123

martinthenth opened this issue Apr 2, 2021 · 1 comment

Comments

@martinthenth
Copy link
Contributor

martinthenth commented Apr 2, 2021

One problem I've had while working with Dgraph, is that Dgraph does not have a test sandbox like Ecto has for Postgres. Since Dgraph does not offer multiple databases in a single instance, I'm wondering how other developers are solving this problem.

To illustrate, when running tests: The test may create new data and fetch old data:

  1. First run: Create node with external_id: "1", returns uid: 0x1, external_id: "1"
  2. First run: Fetch node with external_id: "1", returns uid: 0x1, external_id: "1"
  3. Second run: Create node with external_id: "1", returns uid: 0x2, external_id: "1"
  4. Second run: Fetch node with external_id: "1", returns nodes with uid: 0x1, external_id: "1" and uid: 0x2, external_id: "1"

A workaround I that use, is to add first: 1 and sometimes orderasc: created_on to queries. This works, and makes tests pass using the new data; but adding code simply to make tests work is obviously bad practice.

How are others solving this?

@m0rt3nlund
Copy link
Contributor

This is something I am also wondering about.. We run separate servers just for testing due to this...

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