summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre de Lacroix <pierre@pdelacroix.com>2020-12-09 11:18:25 +0100
committerPierre de Lacroix <pierre@pdelacroix.com>2020-12-09 11:22:20 +0100
commit63842148713c5e5cb3fed07692556d326c210352 (patch)
tree6aa95d3c30e3aae8649cbb2561c9a6c292b733ef
parentdont' start the repo unless necessary (diff)
run formatter
-rw-r--r--lib/matrix_app_service/bridge/room.ex6
-rw-r--r--lib/matrix_app_service/bridge/user.ex6
-rw-r--r--lib/matrix_app_service/bridge_config.ex16
-rw-r--r--lib/matrix_app_service/migrations.ex21
-rw-r--r--test/matrix_app_service/bridge_test.exs46
5 files changed, 56 insertions, 39 deletions
diff --git a/lib/matrix_app_service/bridge/room.ex b/lib/matrix_app_service/bridge/room.ex
index c40e0ed..73ef1ea 100644
--- a/lib/matrix_app_service/bridge/room.ex
+++ b/lib/matrix_app_service/bridge/room.ex
@@ -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
diff --git a/lib/matrix_app_service/bridge/user.ex b/lib/matrix_app_service/bridge/user.ex
index aaa3c46..7bf604a 100644
--- a/lib/matrix_app_service/bridge/user.ex
+++ b/lib/matrix_app_service/bridge/user.ex
@@ -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
diff --git a/lib/matrix_app_service/bridge_config.ex b/lib/matrix_app_service/bridge_config.ex
index 5356caf..68723c6 100644
--- a/lib/matrix_app_service/bridge_config.ex
+++ b/lib/matrix_app_service/bridge_config.ex
@@ -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.
diff --git a/lib/matrix_app_service/migrations.ex b/lib/matrix_app_service/migrations.ex
index e6ce469..6ae5344 100644
--- a/lib/matrix_app_service/migrations.ex
+++ b/lib/matrix_app_service/migrations.ex
@@ -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
diff --git a/test/matrix_app_service/bridge_test.exs b/test/matrix_app_service/bridge_test.exs
index 46acffb..0644f39 100644
--- a/test/matrix_app_service/bridge_test.exs
+++ b/test/matrix_app_service/bridge_test.exs
@@ -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()