View Source EdgeDB.Sandbox (EdgeDB v0.4.0)

Custom connection for tests that involve modifying the database through the driver.

This connection, when started, wraps the actual connection to EdgeDB into a transaction using the start transaction statement. And then further calls to EdgeDB.transaction/3 will result in executing declare savepoint statement instead of start transaction. This connection doesn't affect the availability of the EdgeDB.subtransaction/2 and EdgeDB.subtransaction!/2 calls, you can continue to use them with this module.

To use this module in tests, change the configuration of the :edgedb application in the config/tests.exs:

config :edgedb,
  connection: EdgeDB.Sandbox

Then modify the test case to initialize the sandbox when you run the test and to clean the sandbox at the end of the test:

defmodule MyApp.TestCase do
  use ExUnit.CaseTemplate

  # other stuff for this case (e.g. Phoenix setup, Plug configuration, etc.)

  setup _context do

    on_exit(fn ->


Link to this section Summary


Release the connection transaction.

Wrap a connection in a transaction.

Link to this section Functions

@spec clean(GenServer.server()) :: :ok

Release the connection transaction.

@spec initialize(GenServer.server()) :: :ok

Wrap a connection in a transaction.