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

Ecto 2 Allowances for TestingAdapter #39

Closed
nathany opened this issue Mar 9, 2016 · 4 comments
Closed

Ecto 2 Allowances for TestingAdapter #39

nathany opened this issue Mar 9, 2016 · 4 comments

Comments

@nathany
Copy link

nathany commented Mar 9, 2016

When upgraded a Phoenix project to Ecto 2.0-beta.2 we see the following error in our mailer tests:

** (RuntimeError) cannot find ownership process

There are two solutions to this issue, as documented in Ecto.Adapters.SQL.Sandbox.

For now we're using Shared mode, which works but runs the mailer tests synchronously. To have all the tests run concurrently, we could use Allowances in TestingAdapter:

defmodule Mailman.TestingAdapter do
  @moduledoc "Implementation of the testing SMTP adapter"

  def deliver(config, _email, message) do
    parent = self() # PID of the parent process
    Task.async fn ->
      Ecto.Adapters.SQL.Sandbox.allow(TestRepo, parent, self()) # need MyApp.Repo
      if config.store_deliveries do
        Mailman.TestServer.register_delivery message
      end
      { :ok, message }
    end
  end

end

We've tested this out, but with the name of our Repo hard coded. Do you think it would be possible to get this working?

@keichan34
Copy link
Contributor

Similar situation -- I'm working on making more of my tests async and Ecto 2.0. I'm currently using solutions in my PRs #44 and #45:

@nathany
Copy link
Author

nathany commented Mar 22, 2016

Thanks.

I agree it makes sense to not depend on Ecto. Does using independent test processes have any significant impact on how quickly tests run?

@keichan34
Copy link
Contributor

In my case, it's speeding tests up because the central TestServer was the bottleneck when doing a bunch of mailer tests in parallel.

@nathany
Copy link
Author

nathany commented Mar 23, 2016

Very nice. Thanks a bunch.

I'm gonna close this issue since you're obviously on top of it.

@nathany nathany closed this as completed Mar 23, 2016
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

2 participants