ash icon indicating copy to clipboard operation
ash copied to clipboard

Docs improvement: Testing with references to DataCase & DBConnection.OwnershipError

Open buildreactive opened this issue 4 months ago • 0 comments

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

AI Policy

  • [x] I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.

Is your feature request related to a problem? Please describe.

See this discussion for full context.

While getting a test harness up and running in a new Ash project, I ran into a few hiccups. I think some enhanced documentation would be well worth the investment.

I went back to look at the Ash Test Resources how-to-guide. It’s simplified (ETS) but, only shows how to use ExUnit.Case:

defmodule ActionInvocationTest do
  use ExUnit.Case
  ...

And then there’s the section in Ash Testing, which talks about about turning off async? during testing, which is helpful information but... lacked a bit of context (e.g., when does it really matter, as I was using Postgres I actually did not want to turn it off).

The issue I ran into was, specifically, that most (all?) of the examples used ETS and ExUnit.Case. Nowhere have I found mention of using DataCase. It may be in there, and for someone that uses Ecto a lot, it may be obvious – but it’s not on those two central documents about testing. Might make sense to add it?

In my case, ultimately realizing I should be using DataCase led to instant fixes:

  1. Failing tests started passing (DBConnection.OwnershipError went away, this was hard to track down).
  2. My ExUnit driven doctests started working just fine.

Describe the solution you'd like

Would be great to:

  1. Update docs with examples / highlights on use of DataCase.
  2. Include relevant references to Ecto sources.
  3. Mention that not using DataCase may likely run you into DBConnection.OwnershipError errors cascading all over the place. And break any doctests.

Describe alternatives you've considered

No response

Additional context

No response

buildreactive avatar Aug 05 '25 12:08 buildreactive