mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 13:33:50 +12:00
22 lines
580 B
Elixir
22 lines
580 B
Elixir
|
defmodule AshPostgres.Test.UniqueIdentityTest do
|
||
|
use AshPostgres.RepoCase, async: false
|
||
|
alias AshPostgres.Test.{Api, Post}
|
||
|
|
||
|
require Ash.Query
|
||
|
|
||
|
test "unique constraint errors are properly caught" do
|
||
|
post =
|
||
|
Post
|
||
|
|> Ash.Changeset.new(%{title: "title"})
|
||
|
|> Api.create!()
|
||
|
|
||
|
assert_raise Ash.Error.Invalid,
|
||
|
~r/Invalid value provided for id: has already been taken/,
|
||
|
fn ->
|
||
|
Post
|
||
|
|> Ash.Changeset.new(%{id: post.id})
|
||
|
|> Api.create!()
|
||
|
end
|
||
|
end
|
||
|
end
|