Skip to content

Commit

Permalink
Attempt integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
v0idpwn committed Jun 21, 2023
1 parent 3383f02 commit 0eee8a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion integration_test/cases/repo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,10 +1300,17 @@ defmodule Ecto.Integration.RepoTest do
end

test "virtual field" do
assert %Post{id: id} = TestRepo.insert!(%Post{title: "1"})
assert %Post{id: id} = TestRepo.insert!(%Post{title: "1", temp: "special"})
assert TestRepo.get(Post, id).temp == "temp"
end

test "virtual embed" do
assert %Order{id: id, last_seen_item: %Item{reference: "1"}} =
TestRepo.insert!(%Order{last_seen_item: %Item{reference: "1"}})

assert %{last_seen_item: nil} = TestRepo.get(Order, id)
end

## Query syntax

defmodule Foo do
Expand Down
2 changes: 2 additions & 0 deletions integration_test/support/schemas.exs
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,15 @@ defmodule Ecto.Integration.Order do
* Embedding one schema
* Preloading items inside embeds_many
* Preloading items inside embeds_one
* Virtual embeds
* Field source with json_extract_path
"""
use Ecto.Integration.Schema

schema "orders" do
field :metadata, :map, source: :meta
embeds_one :last_seen_item, Ecto.Integration.Item, virtual: true
embeds_one :item, Ecto.Integration.Item
embeds_many :items, Ecto.Integration.Item
belongs_to :permalink, Ecto.Integration.Permalink
Expand Down

0 comments on commit 0eee8a7

Please sign in to comment.