Verified Commit 63842148 authored by Pierre de Lacroix's avatar Pierre de Lacroix
Browse files

run formatter

parent 36322732
Pipeline #227237531 failed with stage
in 4 minutes and 2 seconds
......@@ -3,9 +3,9 @@ defmodule MatrixAppService.Bridge.Room do
import Ecto.Changeset
schema "rooms" do
field :data, :map
field :local_id, :string
field :remote_id, :string
field(:data, :map)
field(:local_id, :string)
field(:remote_id, :string)
timestamps()
end
......
......@@ -3,9 +3,9 @@ defmodule MatrixAppService.Bridge.User do
import Ecto.Changeset
schema "users" do
field :data, :map
field :local_id, :string
field :remote_id, :string
field(:data, :map)
field(:local_id, :string)
field(:remote_id, :string)
timestamps()
end
......
......@@ -3,7 +3,7 @@ defmodule MatrixAppService.BridgeConfig do
The Bridge config.
"""
defmacro __using__([repo: repo]) do
defmacro __using__(repo: repo) do
quote bind_quoted: [repo: repo] do
@repo repo
......@@ -41,8 +41,11 @@ defmodule MatrixAppService.BridgeConfig do
"""
def get_user!(id), do: @repo.get!(User, id)
def get_user_by_local_id(local_id), do: @repo.get_by(User, local_id: local_id) || %User{local_id: local_id}
def get_user_by_remote_id(remote_id), do: @repo.get_by(User, remote_id: remote_id) || %User{remote_id: remote_id}
def get_user_by_local_id(local_id),
do: @repo.get_by(User, local_id: local_id) || %User{local_id: local_id}
def get_user_by_remote_id(remote_id),
do: @repo.get_by(User, remote_id: remote_id) || %User{remote_id: remote_id}
@doc """
Creates a user.
......@@ -149,8 +152,11 @@ defmodule MatrixAppService.BridgeConfig do
"""
def get_room!(id), do: @repo.get!(Room, id)
def get_room_by_local_id(local_id), do: @repo.get_by(Room, local_id: local_id) || %Room{local_id: local_id}
def get_room_by_remote_id(remote_id), do: @repo.get_by(Room, remote_id: remote_id) || %Room{remote_id: remote_id}
def get_room_by_local_id(local_id),
do: @repo.get_by(Room, local_id: local_id) || %Room{local_id: local_id}
def get_room_by_remote_id(remote_id),
do: @repo.get_by(Room, remote_id: remote_id) || %Room{remote_id: remote_id}
@doc """
Creates a room.
......
......@@ -3,24 +3,25 @@ defmodule MatrixAppService.Migrations do
def change do
create table(:users) do
add :local_id, :string
add :remote_id, :string
add :data, :map
add(:local_id, :string)
add(:remote_id, :string)
add(:data, :map)
timestamps()
end
create unique_index(:users, [:local_id])
create unique_index(:users, [:remote_id])
create(unique_index(:users, [:local_id]))
create(unique_index(:users, [:remote_id]))
create table(:rooms) do
add :local_id, :string
add :remote_id, :string
add :data, :map
add(:local_id, :string)
add(:remote_id, :string)
add(:data, :map)
timestamps()
end
create unique_index(:rooms, [:local_id])
create unique_index(:rooms, [:remote_id])
create(unique_index(:rooms, [:local_id]))
create(unique_index(:rooms, [:remote_id]))
end
end
......@@ -7,7 +7,12 @@ defmodule MatrixAppService.BridgeTest do
alias MatrixAppService.Bridge.User
@valid_attrs %{data: %{}, local_id: "some local_id", remote_id: "some remote_id"}
@update_attrs %{data: %{}, local_id: "some updated local_id", remote_id: "some updated remote_id"}
@update_attrs %{
data: %{},
local_id: "some updated local_id",
remote_id: "some updated remote_id"
}
# @invalid_attrs %{data: nil, local_id: nil, remote_id: nil}
def user_fixture(attrs \\ %{}) do
......@@ -36,9 +41,9 @@ defmodule MatrixAppService.BridgeTest do
assert user.remote_id == "some remote_id"
end
# test "create_user/1 with invalid data returns error changeset" do
# assert {:error, %Ecto.Changeset{}} = Bridge.create_user(@invalid_attrs)
# end
# test "create_user/1 with invalid data returns error changeset" do
# assert {:error, %Ecto.Changeset{}} = Bridge.create_user(@invalid_attrs)
# end
test "update_user/2 with valid data updates the user" do
user = user_fixture()
......@@ -48,11 +53,11 @@ defmodule MatrixAppService.BridgeTest do
assert user.remote_id == "some updated remote_id"
end
# test "update_user/2 with invalid data returns error changeset" do
# user = user_fixture()
# assert {:error, %Ecto.Changeset{}} = Bridge.update_user(user, @invalid_attrs)
# assert user == Bridge.get_user!(user.id)
# end
# test "update_user/2 with invalid data returns error changeset" do
# user = user_fixture()
# assert {:error, %Ecto.Changeset{}} = Bridge.update_user(user, @invalid_attrs)
# assert user == Bridge.get_user!(user.id)
# end
test "delete_user/1 deletes the user" do
user = user_fixture()
......@@ -70,7 +75,12 @@ defmodule MatrixAppService.BridgeTest do
alias MatrixAppService.Bridge.Room
@valid_attrs %{data: %{}, local_id: "some local_id", remote_id: "some remote_id"}
@update_attrs %{data: %{}, local_id: "some updated local_id", remote_id: "some updated remote_id"}
@update_attrs %{
data: %{},
local_id: "some updated local_id",
remote_id: "some updated remote_id"
}
# @invalid_attrs %{data: nil, local_id: nil, remote_id: nil}
def room_fixture(attrs \\ %{}) do
......@@ -99,9 +109,9 @@ defmodule MatrixAppService.BridgeTest do
assert room.remote_id == "some remote_id"
end
# test "create_room/1 with invalid data returns error changeset" do
# assert {:error, %Ecto.Changeset{}} = Bridge.create_room(@invalid_attrs)
# end
# test "create_room/1 with invalid data returns error changeset" do
# assert {:error, %Ecto.Changeset{}} = Bridge.create_room(@invalid_attrs)
# end
test "update_room/2 with valid data updates the room" do
room = room_fixture()
......@@ -111,11 +121,11 @@ defmodule MatrixAppService.BridgeTest do
assert room.remote_id == "some updated remote_id"
end
# test "update_room/2 with invalid data returns error changeset" do
# room = room_fixture()
# assert {:error, %Ecto.Changeset{}} = Bridge.update_room(room, @invalid_attrs)
# assert room == Bridge.get_room!(room.id)
# end
# test "update_room/2 with invalid data returns error changeset" do
# room = room_fixture()
# assert {:error, %Ecto.Changeset{}} = Bridge.update_room(room, @invalid_attrs)
# assert room == Bridge.get_room!(room.id)
# end
test "delete_room/1 deletes the room" do
room = room_fixture()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment