smokestack/test/support/factory.ex
James Harton cb2d0376b5
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
fix: Include :variant in option schema.
This required a bit of a rework of how the options are validated.  Now they're only validated once when `Builder.build` is called instead of inside each builder.
2024-05-28 16:40:43 +12:00

42 lines
1.2 KiB
Elixir

defmodule Support.Factory do
@moduledoc false
use Smokestack
factory Support.Author do
attribute :name, &Faker.Person.name/0
attribute :email, &Faker.Internet.email/0
end
factory Support.Author, :trek do
attribute :name, choose(["JL", "Dr Mark", "BLT", "Cal Hudson"])
attribute :email, fn
%{name: "JL"} -> "captain@entrepreneur.starfleet"
%{name: "Dr Mark"} -> "cheifmed@voyager.starfleet"
%{name: "BLT"} -> "cheifeng@voyager.starfleet"
%{name: "Cal Hudson"} -> "cal@maquis.rebellion"
end
end
factory Support.Post do
domain Support.Domain
attribute :title, &Faker.Commerce.product_name/0
attribute :tags, n_times(3..20, &Faker.Lorem.word/0)
attribute :body, &Faker.Markdown.markdown/0
attribute :sub_title, &Faker.Lorem.sentence/0
end
factory Support.Post, :trek do
attribute :title,
choose([
"On the safety of conference attendance",
"Who would win? Q vs Kevin Uxbridge - an analysis",
"Improvised tools for warp core maintenance",
"Cardassia Prime: Hot or Not?"
])
attribute :body, &Faker.Markdown.markdown/0
end
end