mirror of
https://github.com/danbee/chess
synced 2025-03-04 08:39:06 +00:00
22 lines
413 B
Elixir
22 lines
413 B
Elixir
defmodule Chess.Factory do
|
|
alias Chess.Auth.User
|
|
alias Chess.Store.Game
|
|
alias Chess.Repo
|
|
|
|
def create_user(username \\ "zelda", password \\ "password") do
|
|
User.changeset(
|
|
%User{},
|
|
%{username: username, password: password}
|
|
)
|
|
|> Repo.insert!
|
|
end
|
|
|
|
def create_game_for(user) do
|
|
Game.create_changeset(
|
|
%Game{},
|
|
%{user_id: user.id}
|
|
)
|
|
|> Repo.insert!
|
|
end
|
|
end
|