ash_postgres/test/unique_identity_test.exs
Zach Daniel 7f8aa98f24 improvement: better errors for multitenant unique constraints
fix: un-break the `in` filter type casting code

test: add tests for untested features
2021-01-26 15:07:26 -05:00

21 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