ash_sqlite/test/custom_index_test.exs
2023-09-22 22:52:22 -04:00

24 lines
752 B
Elixir

defmodule AshSqlite.Test.CustomIndexTest do
use AshSqlite.RepoCase, async: false
alias AshSqlite.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