Skip to content

Commit

Permalink
fix: make building invalid types better
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaAK committed May 24, 2024
1 parent 179e572 commit d415ad6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/factory_ex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d415ad6

Please sign in to comment.