From a20ee0abf7db32975c8be9b0ed5a592528d8aa69 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Thu, 6 Apr 2023 10:23:17 -0400 Subject: [PATCH] chore: fix tests/stacktrace setting --- lib/ash/error/error.ex | 2 +- .../relationships/belongs_to_test.exs | 57 ------------------- 2 files changed, 1 insertion(+), 58 deletions(-) diff --git a/lib/ash/error/error.ex b/lib/ash/error/error.ex index 6063e720..6c1daac3 100644 --- a/lib/ash/error/error.ex +++ b/lib/ash/error/error.ex @@ -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 diff --git a/test/resource/relationships/belongs_to_test.exs b/test/resource/relationships/belongs_to_test.exs index 26c0c0c4..66cb0f95 100644 --- a/test/resource/relationships/belongs_to_test.exs +++ b/test/resource/relationships/belongs_to_test.exs @@ -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