Ash FrameworkAF
Ash Framework3y ago
7 replies
Robert Graff

How to compare a seed and loaded resource?

I thought strip_metadata() would make the comparable

user = Ash.Seed.seed!(%User{...})
loaded_user = User.get_by_id!(user.id) |> Ash.Test.strip_metadata()
assert loaded_user == user

     Assertion with == failed
     code:  assert loaded_user == user
     left:  #Iterup.Accounts.User<account: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<>, id: "d4a9ed2e-cfae-4b18-b2a2-d07a0d426854", email: #Ash.CiString<"kitty2075@hessel.com">, name: "Mohammad Abshire", avatar_path: nil, confirmed_at: nil, inserted_at: ~U[2023-04-21 15:49:04.534852Z], updated_at: ~U[2023-04-21 15:49:04.534852Z], account_id: "eeb36be1-a423-4569-81ac-c1256de4fda3", aggregates: %{}, calculations: %{}, __order__: nil, ...>
     right: #Iterup.Accounts.User<account: #Iterup.Accounts.Account<users: #Ash.NotLoaded<:relationship>, invites: #Ash.NotLoaded<:relationship>, __meta__: #Ecto.Schema.Metadata<:loaded, "accounts">, id: "eeb36be1-a423-4569-81ac-c1256de4fda3", name: "Leffler-Connelly", slug: "leffler-connelly", inserted_at: ~U[2023-04-21 15:49:04.375199Z], updated_at: ~U[2023-04-21 15:49:04.375199Z], aggregates: %{}, calculations: %{}, __order__: nil, ...>, __meta__: #Ecto.Schema.Metadata<:loaded, "users">, id: "d4a9ed2e-cfae-4b18-b2a2-d07a0d426854", email: "kitty2075@hessel.com", name: "Mohammad Abshire", avatar_path: nil, confirmed_at: nil, inserted_at: ~U[2023-04-21 15:49:04.534852Z], updated_at: ~U[2023-04-21 15:49:04.534852Z], account_id: "eeb36be1-a423-4569-81ac-c1256de4fda3", aggregates: %{}, calculations: %{}, __order__: nil, ...>


Are there any showcase apps that have some good example test suites?
Was this page helpful?