Update the generators to generate bids.
This commit is contained in:
@@ -63,4 +63,31 @@ defmodule DecentralisedBookIndex.Generators do
|
||||
%{order: order, author_id: generate(author(actor: actor)).id, role: ""}
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Generates a list of bids.
|
||||
|
||||
Example:
|
||||
> bids = bids()
|
||||
"""
|
||||
def bids(opts \\ []) do
|
||||
actor =
|
||||
opts[:actor] ||
|
||||
once(:default_actor, fn ->
|
||||
generate(user())
|
||||
end)
|
||||
|
||||
count =
|
||||
opts[:count] || 2
|
||||
|
||||
types = ["isbn10", "isbn13", "asin"]
|
||||
|
||||
if count > length(types), do: count = length(types)
|
||||
|
||||
random_types = Enum.take_random(types, count)
|
||||
|
||||
for {order, type} <- Enum.zip(1..count, random_types) do
|
||||
%{order: order, type: type, bid: "1234567890"}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user