diff --git a/test/ecto/integration/crud_test.exs b/test/ecto/integration/crud_test.exs index 01ee1ec..a5f92cb 100644 --- a/test/ecto/integration/crud_test.exs +++ b/test/ecto/integration/crud_test.exs @@ -51,6 +51,26 @@ defmodule Ecto.Integration.CrudTest do assert found.tags == [] end + test "inserts product with type set" do + assert {:ok, account} = TestRepo.insert(%Account{name: "Something"}) + + assert {:ok, product} = + TestRepo.insert(%Product{ + name: "Thing", + type: :inventory, + account_id: account.id, + approved_at: nil + }) + + assert found = TestRepo.get(Product, product.id) + assert found.id == product.id + assert found.approved_at == nil + assert found.description == nil + assert found.type == :inventory + assert found.name == "Thing" + assert found.tags == [] + end + test "insert_all" do TestRepo.insert!(%User{name: "John"}, []) timestamp = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second) diff --git a/test/support/migration.ex b/test/support/migration.ex index d1cb67d..3ef3ce2 100644 --- a/test/support/migration.ex +++ b/test/support/migration.ex @@ -30,6 +30,7 @@ defmodule EctoSQLite3.Integration.Migration do add(:external_id, :uuid) add(:bid, :binary_id) add(:tags, {:array, :string}) + add(:type, :integer) add(:approved_at, :naive_datetime) add(:ordered_at, :utc_datetime) add(:price, :decimal) diff --git a/test/support/schemas/product.ex b/test/support/schemas/product.ex index c0b3803..67f25fa 100644 --- a/test/support/schemas/product.ex +++ b/test/support/schemas/product.ex @@ -11,6 +11,7 @@ defmodule EctoSQLite3.Schemas.Product do field(:name, :string) field(:description, :string) field(:external_id, Ecto.UUID) + field(:type, Ecto.Enum, values: [inventory: 1, non_inventory: 2]) field(:bid, :binary_id) field(:tags, {:array, :string}, default: []) field(:approved_at, :naive_datetime) @@ -31,7 +32,8 @@ defmodule EctoSQLite3.Schemas.Product do :account_id, :approved_at, :ordered_at, - :inserted_at + :inserted_at, + :type ]) |> validate_required([:name]) |> maybe_generate_external_id()