test: add test for bulk creating relationships (#147)

This commit is contained in:
Frank Dugan III 2023-05-26 08:13:24 -05:00 committed by GitHub
parent 376717ae36
commit 4704253cc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -63,6 +63,23 @@ defmodule AshPostgres.BulkCreateTest do
nil
end)
end
test "bulk creates can create relationships" do
Api.bulk_create!(
[%{title: "fred", ratings: [%{score: 5}]}, %{title: "george", ratings: [%{score: 0}]}],
Post,
:create
)
assert [
%{title: "fred", ratings: [%{score: 5}]},
%{title: "george", ratings: [%{score: 0}]}
] =
Post
|> Ash.Query.sort(:title)
|> Ash.Query.load(:ratings)
|> Api.read!()
end
end
describe "validation errors" do