Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions test/bulk_create_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,21 @@
|> Ash.read!()
end
end

describe "transaction errors" do
@tag this: "this"
test "transaction errors rolls back" do

Check failure on line 146 in test/bulk_create_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci / mix test

test transaction errors transaction errors rolls back (AshSqlite.BulkCreateTest)
org =
AshSqlite.Test.Organization
|> Ash.Changeset.for_create(:create, %{name: "foo"})
|> Ash.create!()


assert {:error, _} = AshSqlite.Test.Post
|> Ash.Changeset.for_create(:create_with_failing_change, %{organization_id: org.id, title: "foo"})
|> Ash.create()

assert {:ok, []} = Ash.read(AshSqlite.Test.Post)
end
end
end
6 changes: 6 additions & 0 deletions test/support/resources/post.ex
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ defmodule AshSqlite.Test.Post do
destroy :destroy_only_freds do
change(filter(expr(title == "fred")))
end

create :create_with_failing_change do
change after_action(fn _cs, _post, _ctx ->
{:error, field: :org, message: "Failing action"}
end)
end
end

identities do
Expand Down
Loading