chore: fix tests/stacktrace setting

This commit is contained in:
Zach Daniel 2023-04-06 10:23:17 -04:00
parent 80616781d6
commit a20ee0abf7
2 changed files with 1 additions and 58 deletions

View file

@ -367,7 +367,7 @@ defmodule Ash.Error do
%Stacktrace{stacktrace: stacktrace}
end
%{error | stacktrace: stacktrace || fake_stacktrace()}
%{error | stacktrace: stacktrace || error.stacktrace || fake_stacktrace()}
end
defp fake_stacktrace() do

View file

@ -264,61 +264,4 @@ defmodule Ash.Test.Resource.Relationships.BelongsToTest do
end
)
end
test "don't add required error for belongs_to if other errors are present" do
defposts do
actions do
defaults [:create, :read, :update, :destroy]
end
relationships do
has_many(:comments, Comment)
end
end
defcomments do
actions do
defaults [:create]
end
relationships do
belongs_to(:post, Post, allow_nil?: false)
end
end
defmodule Registry do
@moduledoc false
use Ash.Registry
entries do
entry(Post)
entry(Comment)
end
end
defmodule Api do
@moduledoc false
use Ash.Api
resources do
registry Registry
end
end
assert {:error,
%Ash.Error.Invalid{
changeset: %{
errors: [
# there should not be a Ash.Error.Changes.Required error in this list
%Ash.Error.Invalid{path: [:post]}
]
}
}} =
Comment
|> Ash.Changeset.new()
|> Ash.Changeset.manage_relationship(:post, Ecto.UUID.generate(),
type: :append_and_remove
)
|> Api.create()
end
end