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

Allow projectors to be tested directly #26

Open
slashdotdash opened this issue Nov 21, 2019 · 0 comments
Open

Allow projectors to be tested directly #26

slashdotdash opened this issue Nov 21, 2019 · 0 comments

Comments

@slashdotdash
Copy link
Member

slashdotdash commented Nov 21, 2019

Make it possible to test a projector by directly calling a function on the projector module, passing an Ecto.Multi struct, an event, and its metadata.

Examples

Test a projector by projecting a single event:

{:ok, _changes} =
  Ecto.Multi.new()
  |> MyApp.ExampleProjector.project(event, metadata)
  |> MyApp.Repo.transaction()

Test a projector by reducing a list of events:

multi = 
  Enum.reduce(events, Ecto.Multi.new(), fn event, multi ->
    MyApp.ExampleProjector.project(multi, event, metadata)
  end)

{:ok, _changes} = MyApp.Repo.transaction(multi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant