I have the following code in my test:
for i <- 1..15 do
Ash.create(Project, %{owner_id: user.id, name: "Project #{i}"}, authorize?: false)
end
and this assertion:
assert {:ok, paginated_results} = Project.list_paginated(page: [offset: 10, count: true])
Now, these assertions should always pass, but they fail and pass intermittently:
assert length(paginated_result.results) == 5
assert paginated_result.count == 15
Sometimes, the total_count
is 13, sometimes 14, and then 15. Tried using Enum
functions, but got to the same issue and I can’t figure it out.
I am using the default setup for the create
action. I am also using offset pagination, and this is what I have in the list_paginated
action:
read :list_paginated do
pagination offset?: true, default_limit: 10
prepare build(sort: :created_at)
end
I have added this to my config/test.exs
file:
config :ash, :disable_async?, true
but I still get to the same issue.
How can I resolve this?