ash_postgres/test/custom_index_test.exs
Zach Daniel 059837651d improvement: add unique constraints to changeset for custom unique indexes
improvement: separate out concurrent index creations and do them in a separate transaction
2022-11-25 14:06:22 -05:00

24 lines
758 B
Elixir

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