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
|
|
|
|
defmodule Module.concat(["rand#{System.unique_integer([:positive])}", Post]) do
|
|
|
|
@moduledoc false
|
|
|
|
use Ash.Resource, data_layer: Ash.DataLayer.Ets
|
|
|
|
|
|
|
|
attributes do
|
|
|
|
uuid_primary_key :id
|
|
|
|
end
|
|
|
|
|
|
|
|
unquote(body)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-14 08:11:32 +13:00
|
|
|
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
|