testcontainers / testcontainers-elixir

Testcontainers is an Elixir library that supports ExUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
MIT License
98 stars 15 forks source link

Support multiple databases/repos in config #123

Open jarlah opened 7 hours ago

jarlah commented 7 hours ago

When using Commanded we quickly realize that this library is not meant for anything but one repo.

need to look into how we can support multiple repos/configs.

jarlah commented 6 hours ago

Or is it possible ? Specify repo param to postgres_container in ecto module? Is EventStore a Repo .... EDIT: nope:

  @impl true
  def start(_type, _args) do
    if Application.get_env(:testcontainers, :enabled, false) do
      {:ok, _} = Testcontainers.Ecto.postgres_container(app: :journi_plan, repo: JourniPlan.Repo)
      {:ok, _} = Testcontainers.Ecto.postgres_container(app: :journi_plan, repo: JourniPlan.EventStore) |> IO.inspect(label: "EventStore")
    end
** (MatchError) no match of right hand side value: {:error, %UndefinedFunctionError{module: JourniPlan.EventStore, function: :__adapter__, arity: 0, reason: nil, message: nil}}
%UndefinedFunctionError{module: JourniPlan.EventStore, function: :__adapter__, arity: 0, reason: nil, message: nil}
jarlah commented 5 hours ago

actually its severely limited ... and i dont have any good example tests for usage in "normal unit tests"

jarlah commented 3 hours ago

muahaha. Got it working. But will need to think about how to make it a usable thing in testcontainers ;)

https://github.com/jarlah/JourniPlan/pull/4