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