2021-07-28 15:23:48 +00:00
|
|
|
defmodule MatrixServer.QuickCheck do
|
|
|
|
import Ecto.Query
|
|
|
|
|
|
|
|
alias MatrixServer.{Repo, Room, Account, RoomServer}
|
2021-08-14 13:20:42 +00:00
|
|
|
alias MatrixServerWeb.Client.Request.CreateRoom
|
2021-07-28 15:23:48 +00:00
|
|
|
|
2021-07-29 14:59:40 +00:00
|
|
|
def create_room(name \\ nil, topic \\ nil) do
|
2021-07-28 15:23:48 +00:00
|
|
|
account = Repo.one!(from a in Account, limit: 1)
|
2021-07-29 14:59:40 +00:00
|
|
|
input = %CreateRoom{name: name, topic: topic}
|
2021-07-28 15:23:48 +00:00
|
|
|
%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
|