Ecto: Ownership issues when using SQL sandbox

I’ve been following the docs here to set up my tests using the sandbox. However no matter how I end up attempting to set up my tests I end up getting an ownership error.

I was hoping someone could take a look at my new setup (I’m in the middle of a major overhaul of the package) and point out the obvious thing I’m doing wrong. Test file I’m trying to run.

This is continuing to drive me crazy, as I don’t understand at all what is happening. Let me provide a fuller picture compared to what I wrote last night in my late night delirium.

I have a project that I’m doing a rather extensive overhaul on right now. It started out as a full OTP application for use via HEX and so on, and now I’m transforming it into more of an end-user type project which uses an umbrella app as this is going to let me simplify and clarify quite a few things.

At the point of my final commit in my develop branch, I can run mix test and all my tests run perfectly. Here is the setup I use in that branch:

/config.exs
config :exmud, Exmud.Repo,
  adapter: Ecto.Adapters.Postgres,
  database: "exmud_repo",
  username: "exmud_user",
  password: "exmud_password",
  hostname: "localhost",
  port: "5432"

/test.exs
config :exmud, Exmud.Repo,
  username: "postgres",
  password: "",
  database: "exmud_test_repo"

/test_helper.exs
ExUnit.configure(exclude: [pending: true])
ExUnit.start

I don’t use sandbox mode or anything, and everything just works as I expect. I’ve created a new branch for the project to do the overhaul in, and am basically recreating things from the ground up, moving in bits of logic and making sure they work and eventually I’ll just merge in the new completely refactored branch. However I’m getting stuck very early in the process.

I got the umbrella app up and running with my separate db/phoenix/engine apps, but when I attempt to move in my first hefty chunk of logic and start running some tests I simply can’t seem to make the sandbox mode work. This is my setup for what I’m trying to do now and failing:

umbrella/config.exs
import_config "../apps/*/config/config.exs"

db/config.exs
config :exmud_db,
  namespace: Exmud.DB,
  ecto_repos: [Exmud.DB.Repo]

db/test.exs
config :exmud_db, Exmud.DB.Repo,
  adapter: Ecto.Adapters.Postgres,
  username: "exmud",
  password: "exmud",
  database: "exmud_test",
  hostname: "localhost",
  pool: Ecto.Adapters.SQL.Sandbox

db/test_helper.exs
ExUnit.configure(exclude: [pending: true])
ExUnit.start()
Ecto.Adapters.SQL.Sandbox.mode(Exmud.DB.Repo, :manual)

engine/test_helper.exs
ExUnit.configure(exclude: [pending: true])
ExUnit.start()
Ecto.Adapters.SQL.Sandbox.mode(Exmud.DB.Repo, :manual)

engine/object_test.exs
defmodule Exmud.Engine.ObjectTest do
  
  ...
  
  alias Exmud.DB.Repo
  use ExUnit.Case

  describe "Standard Ecto usage tests for game object: " do
    setup [:create_new_object, :setup_db_connection]

  ...

  end

  describe "Multi Ecto usage tests for game object: " do
    setup [:create_new_object_multi, :setup_db_connection]

  ...

  end

  defp setup_db_connection(context) do
    # Explicitly get a connection before each test
    # By default the test is wrapped in a transaction
    :ok = Ecto.Adapters.SQL.Sandbox.checkout(Repo)
  end

  ...

end

However when I run mix test in the umbrella application, the db/web apps pass their basic tests just fine but the engine app, trying to talk to the DB, fails all of its tests with an OwnershipError. I thought this would be taken care of by the test_helper.exs setup, but something seems to be off and I can’t quite figure out what it is. I’m trying to follow these docs. You can see my latest code that I’m trying to get working here at github.

Any guidance would be appreciated.