2023-09-23 14:52:22 +12:00
|
|
|
defmodule AshSqlite.Test.CustomIndexTest do
|
|
|
|
use AshSqlite.RepoCase, async: false
|
2024-04-02 05:18:42 +13:00
|
|
|
alias AshSqlite.Test.Post
|
2023-09-23 14:52:22 +12:00
|
|
|
|
|
|
|
require Ash.Query
|
|
|
|
|
|
|
|
test "unique constraint errors are properly caught" do
|
|
|
|
Post
|
2024-04-02 05:18:42 +13:00
|
|
|
|> 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
|
2024-04-02 05:18:42 +13:00
|
|
|
|> Ash.Changeset.for_create(:create, %{
|
2023-09-23 14:52:22 +12:00
|
|
|
title: "first",
|
|
|
|
uniq_custom_one: "what",
|
|
|
|
uniq_custom_two: "what2"
|
|
|
|
})
|
2024-04-02 05:18:42 +13:00
|
|
|
|> Ash.create!()
|
2023-09-23 14:52:22 +12:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|