fix some code style and add checks to ci
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -36,7 +36,7 @@ defmodule Eventos.AccountsTest do
|
||||
assert account.domain == "some domain"
|
||||
assert account.private_key == "some private_key"
|
||||
assert account.public_key == "some public_key"
|
||||
assert account.suspended == true
|
||||
assert account.suspended
|
||||
assert account.uri == "some uri"
|
||||
assert account.url == "some url"
|
||||
assert account.username == "some username"
|
||||
@@ -55,7 +55,7 @@ defmodule Eventos.AccountsTest do
|
||||
assert account.domain == "some updated domain"
|
||||
assert account.private_key == "some updated private_key"
|
||||
assert account.public_key == "some updated public_key"
|
||||
assert account.suspended == false
|
||||
refute account.suspended
|
||||
assert account.uri == "some updated uri"
|
||||
assert account.url == "some updated url"
|
||||
assert account.username == "some updated username"
|
||||
|
||||
@@ -9,11 +9,11 @@ defmodule Eventos.EventsTest do
|
||||
@account_valid_attrs %{description: "some description", display_name: "some display_name", domain: "some domain", private_key: "some private_key", public_key: "some public_key", suspended: true, uri: "some uri", url: "some url", username: "some username"}
|
||||
@event_valid_attrs %{begins_on: "2010-04-17 14:00:00.000000Z", description: "some description", ends_on: "2010-04-17 14:00:00.000000Z", title: "some title"}
|
||||
|
||||
def account_fixture(attrs \\ %{}) do
|
||||
def account_fixture do
|
||||
insert(:account)
|
||||
end
|
||||
|
||||
def event_fixture(attrs \\ %{}) do
|
||||
def event_fixture do
|
||||
insert(:event, organizer: account_fixture())
|
||||
end
|
||||
|
||||
@@ -274,7 +274,7 @@ defmodule Eventos.EventsTest do
|
||||
event = event_fixture()
|
||||
account = account_fixture()
|
||||
valid_attrs = Map.put(@valid_attrs, :event_id, event.id)
|
||||
|> Map.put(:account_id, account.id)
|
||||
valid_attrs = Map.put(valid_attrs, :account_id, account.id)
|
||||
{:ok, participant} =
|
||||
attrs
|
||||
|> Enum.into(valid_attrs)
|
||||
@@ -297,7 +297,7 @@ defmodule Eventos.EventsTest do
|
||||
account = account_fixture()
|
||||
event = event_fixture()
|
||||
valid_attrs = Map.put(@valid_attrs, :event_id, event.id)
|
||||
|> Map.put(:account_id, account.id)
|
||||
valid_attrs = Map.put(valid_attrs, :account_id, account.id)
|
||||
assert {:ok, %Participant{} = participant} = Events.create_participant(valid_attrs)
|
||||
assert participant.role == 42
|
||||
end
|
||||
|
||||
@@ -32,7 +32,7 @@ defmodule Eventos.GroupsTest do
|
||||
test "create_group/1 with valid data creates a group" do
|
||||
assert {:ok, %Group{} = group} = Groups.create_group(@valid_attrs)
|
||||
assert group.description == "some description"
|
||||
assert group.suspended == true
|
||||
assert group.suspended
|
||||
assert group.title == "some title"
|
||||
assert group.uri == "some uri"
|
||||
assert group.url == "some url"
|
||||
@@ -47,7 +47,7 @@ defmodule Eventos.GroupsTest do
|
||||
assert {:ok, group} = Groups.update_group(group, @update_attrs)
|
||||
assert %Group{} = group
|
||||
assert group.description == "some updated description"
|
||||
assert group.suspended == false
|
||||
refute group.suspended
|
||||
assert group.title == "some updated title"
|
||||
assert group.uri == "some updated uri"
|
||||
assert group.url == "some updated url"
|
||||
|
||||
@@ -6,8 +6,6 @@ defmodule EventosWeb.AccountControllerTest do
|
||||
alias Eventos.Accounts
|
||||
|
||||
@create_attrs %{description: "some description", display_name: "some display_name", domain: "some domain", private_key: "some private_key", public_key: "some public_key", suspended: true, uri: "some uri", url: "some url", username: "some username"}
|
||||
@update_attrs %{description: "some updated description", display_name: "some updated display_name", domain: "some updated domain", private_key: "some updated private_key", public_key: "some updated public_key", suspended: false, uri: "some updated uri", url: "some updated url", username: "some updated username"}
|
||||
@invalid_attrs %{description: nil, display_name: nil, domain: nil, private_key: nil, public_key: nil, suspended: nil, uri: nil, url: nil, username: nil}
|
||||
|
||||
def fixture(:account) do
|
||||
{:ok, account} = Accounts.create_account(@create_attrs)
|
||||
|
||||
@@ -7,7 +7,7 @@ defmodule EventosWeb.UserControllerTest do
|
||||
alias Eventos.Accounts.User
|
||||
|
||||
@create_attrs %{email: "foo@bar.tld", password: "some password_hash", username: "some username"}
|
||||
@update_attrs %{email: "foo@fighters.tld", password: "some updated password_hash", username: "some updated username"}
|
||||
# @update_attrs %{email: "foo@fighters.tld", password: "some updated password_hash", username: "some updated username"}
|
||||
@invalid_attrs %{email: "not an email", password: nil, username: nil}
|
||||
|
||||
def fixture(:user) do
|
||||
@@ -33,6 +33,7 @@ defmodule EventosWeb.UserControllerTest do
|
||||
test "renders user when data is valid", %{conn: conn} do
|
||||
conn = post conn, user_path(conn, :create), @create_attrs
|
||||
assert %{"user" => %{"id" => id}} = json_response(conn, 201)
|
||||
assert id > 0
|
||||
end
|
||||
|
||||
test "renders errors when data is invalid", %{conn: conn} do
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
defmodule Eventos.Factory do
|
||||
@moduledoc """
|
||||
Factory for fixtures with ExMachina
|
||||
"""
|
||||
# with Ecto
|
||||
use ExMachina.Ecto, repo: Eventos.Repo
|
||||
|
||||
@@ -12,7 +15,7 @@ defmodule Eventos.Factory do
|
||||
end
|
||||
|
||||
def account_factory do
|
||||
{:ok, {privkey, pubkey}} = RsaEx.generate_keypair("4096")
|
||||
{:ok, {_, pubkey}} = RsaEx.generate_keypair("4096")
|
||||
%Eventos.Accounts.Account{
|
||||
username: sequence("Thomas"),
|
||||
domain: nil,
|
||||
@@ -47,4 +50,4 @@ defmodule Eventos.Factory do
|
||||
event: build(:event)
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,4 +3,3 @@
|
||||
ExUnit.start()
|
||||
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Eventos.Repo, :manual)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user