Uni Ecto Plugin — [2021]

The Uni Ecto Plugin transforms your data layer into a set of . Part 3: Installation & Basic Setup Let’s get our hands dirty. Add the necessary dependencies to your mix.exs :

:telemetry.attach( "uni-ecto-queries", [:uni, :step, :stop], fn event, measurements, metadata, _config -> if metadata.step_module == Uni.Ecto do IO.puts("Step #metadata.step_name took #measurements.durationns") end end, nil ) Traditional Ecto testing uses Sandbox and explicit repo calls. With Uni, you have three testing options: Option A: Integration Test (Real DB) test "registration inserts a user" do assert :ok, %insert_user: user = UserRegistration.run(%email: "test@test.com") assert Repo.get(User, user.id) != nil end Option B: Mock the Entire Pipeline at the Step Level Uni allows overriding any step’s implementation during testing: uni ecto plugin

alias Uni.Ecto step = Ecto.get(MyApp.Post, post_id) |> Ecto.preload([:comments, :author]) The Uni Ecto Plugin transforms your data layer into a set of