From d415ad6a9988a93a722b5a29a38cd42850781d36 Mon Sep 17 00:00:00 2001 From: MikaAK Date: Fri, 24 May 2024 14:46:04 -0400 Subject: [PATCH] fix: make building invalid types better --- lib/factory_ex.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/factory_ex.ex b/lib/factory_ex.ex index 590ff16..da566be 100644 --- a/lib/factory_ex.ex +++ b/lib/factory_ex.ex @@ -97,14 +97,16 @@ defmodule FactoryEx do field = schema.__schema__(:fields) |> Kernel.--([:updated_at, :inserted_at, :id]) |> Enum.reject(&(schema.__schema__(:type, &1) === :id)) - |> Enum.random + |> Enum.shuffle + |> Enum.take(2) field_type = schema.__schema__(:type, field) field_value = case field_type do :integer -> "asdfd" :string -> 1239 - _ -> 4321 + :float -> "string" + _ -> {:invalid_type, 1} end Map.put(params, field, field_value)