Finally fix backend tests

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-06-04 16:32:26 +02:00
parent f480936eb4
commit f100fce0da
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
5 changed files with 21 additions and 12 deletions

View File

@ -12,7 +12,7 @@ defmodule Mix.Tasks.Mobilizon.Common do
def start_mobilizon do
if mix_task?(), do: Mix.Task.run("app.config")
unless System.get_env("DEBUG") do
unless System.get_env("DEBUG") || Application.fetch_env!(:mobilizon, :env) == :test do
Logger.configure(level: :error)
end

View File

@ -260,6 +260,7 @@ defmodule Mobilizon.GraphQL.Resolvers.ActivityTest do
group: %Actor{preferred_username: preferred_username, id: group_id} = group
} do
user = insert(:user)
insert(:settings, user_id: user.id, user: user)
actor = insert(:actor, user: user)
insert(:member,

View File

@ -10,6 +10,7 @@ defmodule Mobilizon.Service.Workers.ActivityBuilderTest do
alias Mobilizon.Users.User
use Mobilizon.DataCase
use Mobilizon.Tests.Helpers
import Mobilizon.Factory
import Mox
@ -17,7 +18,7 @@ defmodule Mobilizon.Service.Workers.ActivityBuilderTest do
setup_all do
Mox.defmock(NotifierMock, for: Mobilizon.Service.Notifier)
Mobilizon.Config.put([Mobilizon.Service.Notifier, :notifiers], [
clear_config([Mobilizon.Service.Notifier, :notifiers], [
NotifierMock
])

View File

@ -9,17 +9,18 @@ defmodule Mobilizon.Service.Workers.LegacyNotifierBuilderTest do
alias Mobilizon.Events.Event
alias Mobilizon.Service.Notifier.Mock, as: NotifierMock
alias Mobilizon.Service.Workers.LegacyNotifierBuilder
alias Mobilizon.Users.User
alias Mobilizon.Users.{Setting, User}
use Mobilizon.DataCase, async: true
use Mobilizon.DataCase
use Mobilizon.Tests.Helpers
import Mox
import Mobilizon.Factory
setup_all do
Mox.defmock(Mobilizon.Service.Notifier.Mock, for: Mobilizon.Service.Notifier)
Mox.defmock(NotifierMock, for: Mobilizon.Service.Notifier)
Mobilizon.Config.put([Mobilizon.Service.Notifier, :notifiers], [
Mobilizon.Service.Notifier.Mock
clear_config([Mobilizon.Service.Notifier, :notifiers], [
NotifierMock
])
:ok
@ -56,8 +57,8 @@ defmodule Mobilizon.Service.Workers.LegacyNotifierBuilderTest do
args =
Map.merge(@mentionned, %{
"subject_params" => %{
event_uuid: uuid,
event_title: title
"event_uuid" => uuid,
"event_title" => title
},
"author_id" => actor_id,
"object_id" => to_string(comment_id),
@ -82,6 +83,8 @@ defmodule Mobilizon.Service.Workers.LegacyNotifierBuilderTest do
test "if the actor mentionned is local" do
%User{} = user1 = insert(:user)
%User{} = user2 = insert(:user)
%Setting{} = settings2 = insert(:settings, user: user2, user_id: user2.id)
user2 = %User{user2 | settings: settings2}
%Actor{id: actor_id} = actor = insert(:actor, user: user1)
%Actor{id: actor_id_2} = insert(:actor, user: user2)
@ -92,8 +95,8 @@ defmodule Mobilizon.Service.Workers.LegacyNotifierBuilderTest do
args =
Map.merge(@mentionned, %{
"subject_params" => %{
event_uuid: uuid,
event_title: title
"event_uuid" => uuid,
"event_title" => title
},
"author_id" => actor_id,
"object_id" => to_string(comment_id),
@ -155,6 +158,8 @@ defmodule Mobilizon.Service.Workers.LegacyNotifierBuilderTest do
test "if there's some participants" do
%User{} = user1 = insert(:user)
%User{} = user2 = insert(:user)
%Setting{} = settings2 = insert(:settings, user: user2, user_id: user2.id)
user2 = %User{user2 | settings: settings2}
%Actor{id: actor_id} = actor = insert(:actor, user: user1)
%Actor{} = actor2 = insert(:actor, user: user2)

View File

@ -31,7 +31,9 @@ defmodule Mobilizon.Factory do
notification_before_event: false,
notification_pending_participation: :one_day,
notification_pending_membership: :one_day,
user_id: nil
group_notifications: :one_day,
last_notification_sent: nil,
user: build(:user)
}
end