ash/test/support/helpers.ex

34 lines
701 B
Elixir
Raw Normal View History

2021-06-06 10:11:09 +12:00
defmodule Ash.Test.Helpers do
@moduledoc false
2022-04-07 17:52:59 +12:00
defmacro defposts(do: body) do
quote do
{:module, mod, _, _} =
defmodule Module.concat(["rand#{System.unique_integer([:positive])}", Post]) do
@moduledoc false
use Ash.Resource, data_layer: Ash.DataLayer.Ets
2022-04-07 17:52:59 +12:00
attributes do
uuid_primary_key :id
end
unquote(body)
2022-04-07 17:52:59 +12:00
end
mod
2022-04-07 17:52:59 +12:00
end
end
defmacro hydrated_expr(resource, expr) do
quote do
Ash.Query.expr(unquote(expr))
|> Ash.Filter.hydrate_refs(%{
resource: unquote(resource),
aggregates: %{},
calculations: %{},
public?: false
})
end
end
2021-06-06 10:11:09 +12:00
end