mirror of
https://github.com/danbee/chess
synced 2025-03-04 08:39:06 +00:00
36 lines
639 B
Elixir
36 lines
639 B
Elixir
defmodule Chess.Factory do
|
|
@moduledoc false
|
|
|
|
alias Chess.Store.User
|
|
alias Chess.Store.Game
|
|
alias Chess.Repo
|
|
|
|
def insert(_resource, _params \\ %{})
|
|
|
|
def insert(:user, params) do
|
|
%User{
|
|
name: "Zelda",
|
|
email: "zelda@hyrule.com",
|
|
password: "ganonsucks"
|
|
}
|
|
|> User.changeset(params)
|
|
|> Repo.insert!
|
|
end
|
|
|
|
def insert(:opponent, params) do
|
|
%User{
|
|
name: "Link",
|
|
email: "link@hyrule.com",
|
|
password: "ilovezelda"
|
|
}
|
|
|> User.changeset(params)
|
|
|> Repo.insert!
|
|
end
|
|
|
|
def insert(:game, params) do
|
|
%Game{}
|
|
|> Game.changeset(params)
|
|
|> Repo.insert!
|
|
end
|
|
end
|