ash_sqlite/test/custom_index_test.exs

29 lines
801 B
Elixir
Raw Normal View History

2023-09-23 14:52:22 +12:00
defmodule AshSqlite.Test.CustomIndexTest do
use AshSqlite.RepoCase, async: false
alias AshSqlite.Test.Post
2023-09-23 14:52:22 +12:00
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!()
2023-09-23 14:52:22 +12:00
assert_raise Ash.Error.Invalid,
~r/Invalid value provided for uniq_custom_one: dude what the heck/,
fn ->
Post
|> Ash.Changeset.for_create(:create, %{
2023-09-23 14:52:22 +12:00
title: "first",
uniq_custom_one: "what",
uniq_custom_two: "what2"
})
|> Ash.create!()
2023-09-23 14:52:22 +12:00
end
end
end