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

Wiki Testing section is outdated #498

Open
suzdalnitski opened this issue Aug 16, 2022 · 1 comment
Open

Wiki Testing section is outdated #498

suzdalnitski opened this issue Aug 16, 2022 · 1 comment

Comments

@suzdalnitski
Copy link

The EventStore.Storage.Initializer.reset! signature has changed, therefore we now have to do:

config = Conduit.EventStore.config()

{:ok, conn} = Postgrex.start_link(config)

EventStore.Storage.Initializer.reset!(conn, config)

Also I've been unable to get the test setup working with TRUNCATE TABLE for some reason (is the recommended setup perhaps not working with the latest version of Ecto?). However, the Ecto sandbox works perfectly fine, and can be set up in the following way:

defmodule Conduit.DataCase do
  use ExUnit.CaseTemplate

  using do
    ...
  end

  def setup_sandbox() do
    pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Conduit.Repo, shared: true)
    on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
  end

  def setup_storage() do
    {:ok, _} = Application.ensure_all_started(:conduit)

    on_exit(fn ->
      :ok = Application.stop(:conduit)

      Conduit.Storage.reset!()
    end)
  end

  setup tags do
    setup_storage()
    setup_sandbox()

    :ok
  end
end

And in config/test.exs:

config :conduit, Conduit.Repo,
  ...
  pool: Ecto.Adapters.SQL.Sandbox
@suzdalnitski
Copy link
Author

Would also be helpful to add the required mix aliases (in mix.exs), I extracted the following from the Conduit app:

  defp aliases do
    [
      "event_store.init": ["event_store.drop", "event_store.create", "event_store.init"],
      "ecto.setup": ["ecto.create --quiet", "ecto.migrate --quiet", "run priv/repo/seeds.exs"],
      reset: ["event_store.init", "ecto.drop", "ecto.setup"],
      test: ["reset", "test"]
    ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant