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

Commanded.ProcessManagers.ProcessManager.identity/0 function returns nil in unit tests #539

Open
jvantuyl opened this issue Aug 22, 2023 · 0 comments

Comments

@jvantuyl
Copy link

When doing unit tests of process manager callback modules, the Commanded.ProcessManagers.ProcessManager.identity/0 function returns nil. It's easy enough to set the identity during the test with Process.put(:process_uuid, id), but that builds tests that rely on the internals of Commanded.

It would be useful to have a test helper that can be used with ExUnit.Callbacks.setup/1 like this:

defmodule Commanded.TestHelpers do
  def with_process_manager_identity(id, _context) do
    Process.put(:process_uuid, id)
  end
end

And we could use it in tests like this:

defmodule MyAppTest.SomeTest do
  use MyAppTest.Case, async: true
  # MyApp.TestCase impots Commanded.TestHelpers

  setup do
    with_process_manager_identity "my_uuid"
  end
end
@jvantuyl jvantuyl changed the title Commanded.ProcessManagers.ProcessManager.identity/0 function returns nil in unit tests Commanded.ProcessManagers.ProcessManager.identity/0 function returns nil in unit tests Aug 22, 2023
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