ash_postgres/test/custom_index_test.exs
Zach Daniel 37cc01957d
improvement!: 3.0 (#227)
* WIP

* chore: fix mix.lock merge issues

* improvement: upgrade to 3.0

* chore: remove `repo.to_tenant`

* chore: continue removal of unnecessary helper

* chore: use `Ash.ToTenant`
2024-03-27 16:52:28 -04:00

28 lines
807 B
Elixir

defmodule AshPostgres.Test.CustomIndexTest do
use AshPostgres.RepoCase, async: false
alias AshPostgres.Test.Post
require Ash.Query
test "unique constraint errors are properly caught" do
Post
|> Ash.Changeset.for_create(:create, %{
title: "first",
uniq_custom_one: "what",
uniq_custom_two: "what2"
})
|> Ash.create!()
assert_raise Ash.Error.Invalid,
~r/Invalid value provided for uniq_custom_one: dude what the heck/,
fn ->
Post
|> Ash.Changeset.for_create(:create, %{
title: "first",
uniq_custom_one: "what",
uniq_custom_two: "what2"
})
|> Ash.create!()
end
end
end