commanded / commanded/commanded

Wiki Testing section is outdated

Open
#498 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Elixir
Stars
2k
Forks
258
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the Wiki Testing section and compare its EventStore.Storage.Initializer.reset! example with the updated conn/config form in the issue. Review the setup_sandbox and setup_storage examples and config/test.exs, then update the documentation to show the working Ecto sandbox setup and current reset call.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir, postgresql
Domain
database, documentation, testing
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.