architex/test/support/factory.ex
2021-09-01 14:43:55 +02:00

24 lines
625 B
Elixir

defmodule Architex.Factory do
use ExMachina.Ecto, repo: Architex.Repo
alias Architex.{Account, Device}
def account_factory do
%Account{
localpart: sequence(:localpart, &"account#{&1}"),
password_hash: Bcrypt.hash_pwd_salt("lemmein")
}
end
def device_factory do
%Account{localpart: localpart} = account = build(:account)
device_id = sequence(:device_id, &"device#{&1}")
%Device{
device_id: device_id,
access_token: Device.generate_access_token(localpart, device_id),
display_name: sequence(:display_name, &"Device #{&1}"),
account: account
}
end
end