Skip to content

Commit a09f848

Browse files
committed
test: add exists calculation tests for atomic validations
1 parent c12d61d commit a09f848

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

test/atomics_test.exs

+24-23
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ defmodule AshPostgres.AtomicsTest do
33
alias AshPostgres.Test.Comment
44

55
use AshPostgres.RepoCase, async: false
6+
67
alias AshPostgres.Test.Invite
78
alias AshPostgres.Test.Post
89
alias AshPostgres.Test.User
@@ -367,29 +368,29 @@ defmodule AshPostgres.AtomicsTest do
367368
|> Ash.update!()
368369
end
369370

370-
# assert_raise Ash.Error.Invalid, ~r/Can only update if Post has no comments/, fn ->
371-
# post
372-
# |> Ash.Changeset.new()
373-
# |> Ash.Changeset.put_context(:aggregate, unquote(aggregate))
374-
# |> Ash.Changeset.for_update(:update_if_no_comments_non_atomic, %{title: "bar"})
375-
# |> Ash.update!()
376-
# end
377-
378-
# assert_raise Ash.Error.Invalid, ~r/Can only delete if Post has no comments/, fn ->
379-
# post
380-
# |> Ash.Changeset.new()
381-
# |> Ash.Changeset.put_context(:aggregate, unquote(aggregate))
382-
# |> Ash.Changeset.for_destroy(:destroy_if_no_comments_non_atomic, %{})
383-
# |> Ash.destroy!()
384-
# end
385-
386-
# assert_raise Ash.Error.Invalid, ~r/Can only delete if Post has no comments/, fn ->
387-
# post
388-
# |> Ash.Changeset.new()
389-
# |> Ash.Changeset.put_context(:aggregate, unquote(aggregate))
390-
# |> Ash.Changeset.for_destroy(:destroy_if_no_comments, %{})
391-
# |> Ash.destroy!()
392-
# end
371+
assert_raise Ash.Error.Invalid, ~r/Can only update if Post has no comments/, fn ->
372+
post
373+
|> Ash.Changeset.new()
374+
|> Ash.Changeset.put_context(:aggregate, unquote(aggregate))
375+
|> Ash.Changeset.for_update(:update_if_no_comments_non_atomic, %{title: "bar"})
376+
|> Ash.update!()
377+
end
378+
379+
assert_raise Ash.Error.Invalid, ~r/Can only delete if Post has no comments/, fn ->
380+
post
381+
|> Ash.Changeset.new()
382+
|> Ash.Changeset.put_context(:aggregate, unquote(aggregate))
383+
|> Ash.Changeset.for_destroy(:destroy_if_no_comments_non_atomic, %{})
384+
|> Ash.destroy!()
385+
end
386+
387+
assert_raise Ash.Error.Invalid, ~r/Can only delete if Post has no comments/, fn ->
388+
post
389+
|> Ash.Changeset.new()
390+
|> Ash.Changeset.put_context(:aggregate, unquote(aggregate))
391+
|> Ash.Changeset.for_destroy(:destroy_if_no_comments, %{})
392+
|> Ash.destroy!()
393+
end
393394
end
394395
end
395396
)

0 commit comments

Comments
 (0)