title: "Could not lookup Ecto repo" error during tests
body: <p>I've been getting the following exception when trying to setup a new ecto repo. Currently only using it for testing (since i am just setting this up).</p>
  <p><code>** (RuntimeError) could not lookup Ecto repo Lipwig.AnnotatedUnit.Repo because it was not started or it does not exist</code></p>
  <p>This happens when my tests use <code>Lipwig.AnnotatedUnit.DataCase</code>. However, when i use <code>Lipwig.DataCase</code> (which references the Lipwig.Repo`), the tests run fine.</p>
  <p>I have the following setup in the project.</p>
  <pre><code>defmodule Lipwig.Repo do
    use Ecto.Repo,
      otp_app: :lipwig,
      adapter: Ecto.Adapters.Postgres
  end
  
  defmodule Lipwig.AnnotatedUnit.Repo do
    use Ecto.Repo,
      otp_app: :lipwig,
      adapter: Ecto.Adapters.Postgres
  end
  </code></pre>
  <p>This here is my test setup</p>
  <pre><code>defmodule Lipwig.DataCase do
    use ExUnit.CaseTemplate
  
    using do
      quote do
        alias Lipwig.Repo
  
        import Ecto
        import Ecto.Changeset
        import Ecto.Query
        import Lipwig.DataCase
      end
    end
  
    setup tags do
      :ok = Ecto.Adapters.SQL.Sandbox.checkout(Lipwig.Repo)
  
      unless tags[:async] do
        Ecto.Adapters.SQL.Sandbox.mode(Lipwig.Repo, {:shared, self()})
      end
  
      :ok
    end
  
    def errors_on(changeset) do
      Ecto.Changeset.traverse_errors(changeset, fn {message, opts} -&gt;
        Regex.replace(~r&quot;%{(\w+)}&quot;, message, fn _, key -&gt;
          opts |&gt; Keyword.get(String.to_existing_atom(key), key) |&gt; to_string()
        end)
      end)
    end
  end
  
  defmodule Lipwig.AnnotatedUnit.DataCase do
    use ExUnit.CaseTemplate
  
    using do
      quote do
        alias Lipwig.AnnotatedUnit.Repo
  
        import Ecto
        import Ecto.Changeset
        import Ecto.Query
        import Lipwig.AnnotatedUnit.DataCase
      end
    end
  
    setup tags do
      :ok = Ecto.Adapters.SQL.Sandbox.checkout(Lipwig.AnnotatedUnit.Repo)
  
      unless tags[:async] do
        Ecto.Adapters.SQL.Sandbox.mode(Lipwig.AnnotatedUnit.Repo, {:shared, self()})
      end
  
      :ok
    end
  
    def errors_on(changeset) do
      Ecto.Changeset.traverse_errors(changeset, fn {message, opts} -&gt;
        Regex.replace(~r&quot;%{(\w+)}&quot;, message, fn _, key -&gt;
          opts |&gt; Keyword.get(String.to_existing_atom(key), key) |&gt; to_string()
        end)
      end)
    end
  end
  </code></pre>
  <p>My other datacase for <code>Lipwig.Repo</code> is almost identical, just referencing the other repo.</p>
  <p>My <code>config.exs</code> config defines</p>
  <pre><code>config :lipwig,
    ecto_repos: [Lipwig.Repo, Lipwig.AnnotatedUnit.Repo]
  </code></pre>
  <p>My <code>test.exs</code> config is</p>
  <pre><code>config :lipwig, Lipwig.Repo,
    username: &quot;postgres&quot;,
    password: &quot;postgres&quot;,
    database: &quot;lipwig_test&quot;,
    hostname: &quot;localhost&quot;,
    pool: Ecto.Adapters.SQL.Sandbox
  
  config :lipwig, Lipwig.AnnotatedUnit.Repo,
    username: &quot;postgres&quot;,
    password: &quot;postgres&quot;,
    database: &quot;lipwig_test&quot;,
    hostname: &quot;localhost&quot;,
    pool: Ecto.Adapters.SQL.Sandbox
  </code></pre>