Add start of controller testing
This commit is contained in:
parent
598af7a884
commit
096c99df92
14 changed files with 106 additions and 87 deletions
24
test/support/factory.ex
Normal file
24
test/support/factory.ex
Normal file
|
@ -0,0 +1,24 @@
|
|||
defmodule MatrixServer.Factory do
|
||||
use ExMachina.Ecto, repo: MatrixServer.Repo
|
||||
|
||||
alias MatrixServer.{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
|
Loading…
Add table
Add a link
Reference in a new issue