architex/lib/matrix_server/quick_check.ex

15 lines
487 B
Elixir
Raw Normal View History

defmodule MatrixServer.QuickCheck do
import Ecto.Query
alias MatrixServer.{Repo, Room, Account, RoomServer}
2021-08-06 21:14:27 +00:00
alias MatrixServerWeb.Request.CreateRoom
def create_room(name \\ nil, topic \\ nil) do
account = Repo.one!(from a in Account, limit: 1)
input = %CreateRoom{name: name, topic: topic}
%Room{id: room_id} = Repo.insert!(Room.create_changeset(input))
{:ok, pid} = RoomServer.get_room_server(room_id)
RoomServer.create_room(pid, account, input)
end
end