mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-19 21:13:19 +12:00
test: add test confirming embedded array behavior
This commit is contained in:
parent
360274c7c0
commit
01d1a8aa5d
2 changed files with 19 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
defmodule AshPostgres.EmbeddableResourceTest do
|
||||
@moduledoc false
|
||||
use AshPostgres.RepoCase, async: false
|
||||
alias AshPostgres.Test.{Api, Post}
|
||||
alias AshPostgres.Test.{Api, Author, Bio, Post}
|
||||
|
||||
require Ash.Query
|
||||
|
||||
|
@ -18,4 +18,17 @@ defmodule AshPostgres.EmbeddableResourceTest do
|
|||
assert %{calc_returning_json: %AshPostgres.Test.Money{amount: 100, currency: :usd}} =
|
||||
Api.load!(post, :calc_returning_json)
|
||||
end
|
||||
|
||||
test "embeds with list attributes set to nil are loaded as nil" do
|
||||
post =
|
||||
Author
|
||||
|> Ash.Changeset.new(%{bio: %Bio{list_of_strings: nil}})
|
||||
|> Api.create!()
|
||||
|
||||
assert is_nil(post.bio.list_of_strings)
|
||||
|
||||
post = Api.reload!(post)
|
||||
|
||||
assert is_nil(post.bio.list_of_strings)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,5 +10,10 @@ defmodule AshPostgres.Test.Bio do
|
|||
attribute(:title, :string)
|
||||
attribute(:bio, :string)
|
||||
attribute(:years_of_experience, :integer)
|
||||
|
||||
attribute :list_of_strings, {:array, :string} do
|
||||
allow_nil?(true)
|
||||
default(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue