diff --git a/.credo.exs b/.credo.exs index 73296ec7..0a8c81f7 100644 --- a/.credo.exs +++ b/.credo.exs @@ -130,6 +130,7 @@ {Credo.Check.Refactor.NegatedConditionsInUnless, []}, {Credo.Check.Refactor.NegatedConditionsWithElse, []}, {Credo.Check.Refactor.Nesting, []}, + {Credo.Check.Refactor.PassAsyncInTestCases, []}, {Credo.Check.Refactor.RedundantWithClauseResult, []}, {Credo.Check.Refactor.RejectReject, []}, {Credo.Check.Refactor.UnlessWithElse, []}, @@ -198,7 +199,6 @@ {Credo.Check.Refactor.MapMap, []}, {Credo.Check.Refactor.ModuleDependencies, []}, {Credo.Check.Refactor.NegatedIsNil, []}, - {Credo.Check.Refactor.PassAsyncInTestCases, []}, {Credo.Check.Refactor.PipeChainStart, []}, {Credo.Check.Refactor.RejectFilter, []}, {Credo.Check.Refactor.VariableRebinding, []}, diff --git a/test/mindwendel/accounts_test.exs b/test/mindwendel/accounts_test.exs index 91f82a4d..79d8688d 100644 --- a/test/mindwendel/accounts_test.exs +++ b/test/mindwendel/accounts_test.exs @@ -1,5 +1,5 @@ defmodule Mindwendel.AccountsTest do - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true alias Mindwendel.Factory alias Mindwendel.Accounts alias Mindwendel.Accounts.User @@ -125,13 +125,16 @@ defmodule Mindwendel.AccountsTest do ) # we want to make sure that the database is not handling this with a foreign key restraint, but rather that it's handled in the app: - {_result, log} = - with_log(fn -> + log = + capture_log(fn -> Accounts.delete_inactive_users() end) assert Repo.exists?(from u in User, where: u.id == ^old_user.id) - assert log == "" + # we don't expect actual logs but due to async running other tests may emit logs at + # the same time and so we want to make sure here that no delete logs around the user + # are emitted + refute log =~ ~r/delet.*#{old_user.id}/i end end end diff --git a/test/mindwendel/attachments_test.exs b/test/mindwendel/attachments_test.exs index 37b172e4..19351d33 100644 --- a/test/mindwendel/attachments_test.exs +++ b/test/mindwendel/attachments_test.exs @@ -1,5 +1,6 @@ defmodule Mindwendel.AttachmentsTest do - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true + alias Mindwendel.Factory alias Mindwendel.Attachments diff --git a/test/mindwendel/brainstormings/create_brainstorming_test.exs b/test/mindwendel/brainstormings/create_brainstorming_test.exs index f1afe6eb..ef01512f 100644 --- a/test/mindwendel/brainstormings/create_brainstorming_test.exs +++ b/test/mindwendel/brainstormings/create_brainstorming_test.exs @@ -1,5 +1,5 @@ defmodule Mindwendel.Brainstormings.CreateBrainstormingTest do - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true alias Mindwendel.Brainstormings.BrainstormingModeratingUser alias Mindwendel.Accounts.BrainstormingUser alias Mindwendel.Factory diff --git a/test/mindwendel/brainstormings_test.exs b/test/mindwendel/brainstormings_test.exs index 1340ed31..0f85d1fe 100644 --- a/test/mindwendel/brainstormings_test.exs +++ b/test/mindwendel/brainstormings_test.exs @@ -1,6 +1,6 @@ defmodule Mindwendel.BrainstormingsTest do alias Mindwendel.Brainstormings.IdeaIdeaLabel - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true alias Mindwendel.Brainstormings.BrainstormingModeratingUser alias Mindwendel.Factory diff --git a/test/mindwendel/brainstormings_users_test.exs b/test/mindwendel/brainstormings_users_test.exs index b5352e4f..047c0795 100644 --- a/test/mindwendel/brainstormings_users_test.exs +++ b/test/mindwendel/brainstormings_users_test.exs @@ -1,5 +1,5 @@ defmodule Mindwendel.AccountsMergeBrainstormingUserTest do - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true alias Mindwendel.Factory alias Mindwendel.Accounts alias Mindwendel.Accounts.User diff --git a/test/mindwendel/csv_formatter_test.exs b/test/mindwendel/csv_formatter_test.exs index 97f54f47..1a917528 100644 --- a/test/mindwendel/csv_formatter_test.exs +++ b/test/mindwendel/csv_formatter_test.exs @@ -1,5 +1,5 @@ defmodule MindwendelServices.CSVFormatter do - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true alias Mindwendel.Factory alias Mindwendel.CSVFormatter diff --git a/test/mindwendel/help_test.exs b/test/mindwendel/help_test.exs index 53975617..349c500c 100644 --- a/test/mindwendel/help_test.exs +++ b/test/mindwendel/help_test.exs @@ -1,5 +1,5 @@ defmodule Mindwendel.HelpTest do - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true alias Mindwendel.Factory alias Mindwendel.Help diff --git a/test/mindwendel/idea_idea_label_test.exs b/test/mindwendel/idea_idea_label_test.exs index 79bbb9ee..e6f1e72e 100644 --- a/test/mindwendel/idea_idea_label_test.exs +++ b/test/mindwendel/idea_idea_label_test.exs @@ -1,5 +1,5 @@ defmodule Mindwendel.IdeaIdeaLabelTest do - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true alias Mindwendel.Factory alias Mindwendel.Brainstormings.IdeaIdeaLabel diff --git a/test/mindwendel/idea_labels_test.exs b/test/mindwendel/idea_labels_test.exs index 53bc5f80..83991037 100644 --- a/test/mindwendel/idea_labels_test.exs +++ b/test/mindwendel/idea_labels_test.exs @@ -1,5 +1,5 @@ defmodule Mindwendel.IdeaLabelsTest do - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true alias Mindwendel.Factory alias Mindwendel.Ideas diff --git a/test/mindwendel/idea_test.exs b/test/mindwendel/idea_test.exs index ac5eae7d..f7c4cd35 100644 --- a/test/mindwendel/idea_test.exs +++ b/test/mindwendel/idea_test.exs @@ -1,5 +1,5 @@ defmodule Mindwendel.IdeaTest do - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true alias Mindwendel.Factory alias Mindwendel.Ideas diff --git a/test/mindwendel/ideas_test.exs b/test/mindwendel/ideas_test.exs index 786cbd3c..f3f466bf 100644 --- a/test/mindwendel/ideas_test.exs +++ b/test/mindwendel/ideas_test.exs @@ -1,5 +1,5 @@ defmodule Mindwendel.IdeasTest do - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true alias Mindwendel.Factory alias Mindwendel.Ideas diff --git a/test/mindwendel/lanes_test.exs b/test/mindwendel/lanes_test.exs index b81b0063..e10dbc68 100644 --- a/test/mindwendel/lanes_test.exs +++ b/test/mindwendel/lanes_test.exs @@ -1,5 +1,5 @@ defmodule Mindwendel.LanesTest do - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true alias Mindwendel.Lanes alias Mindwendel.Brainstormings.Lane import Mindwendel.BrainstormingsFixtures diff --git a/test/mindwendel/likes_test.exs b/test/mindwendel/likes_test.exs index b6e356ce..883ececb 100644 --- a/test/mindwendel/likes_test.exs +++ b/test/mindwendel/likes_test.exs @@ -1,5 +1,5 @@ defmodule Mindwendel.LikesTest do - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true alias Mindwendel.Factory alias Mindwendel.Likes diff --git a/test/mindwendel/services/storage_service_test.exs b/test/mindwendel/services/storage_service_test.exs index e4526b6d..d68c6c14 100644 --- a/test/mindwendel/services/storage_service_test.exs +++ b/test/mindwendel/services/storage_service_test.exs @@ -1,5 +1,6 @@ defmodule Mindwendel.Brainstormings.StorageServiceTest do - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true + alias Mindwendel.Services.StorageService describe "#store_file" do diff --git a/test/mindwendel/url_preview_test.exs b/test/mindwendel/url_preview_test.exs index ed67d47d..3b86ac7b 100644 --- a/test/mindwendel/url_preview_test.exs +++ b/test/mindwendel/url_preview_test.exs @@ -1,5 +1,5 @@ defmodule MindwendelServices.UrlPreviewTest do - use ExUnit.Case + use ExUnit.Case, async: true alias Mindwendel.UrlPreview setup do diff --git a/test/mindwendel_web/channels/brainstorming_channel_test.exs b/test/mindwendel_web/channels/brainstorming_channel_test.exs index 97405458..45d408be 100644 --- a/test/mindwendel_web/channels/brainstorming_channel_test.exs +++ b/test/mindwendel_web/channels/brainstorming_channel_test.exs @@ -1,5 +1,5 @@ defmodule MindwendelWeb.BrainstormingChannelTest do - use MindwendelWeb.ChannelCase + use MindwendelWeb.ChannelCase, async: true alias Mindwendel.Factory alias Mindwendel.Brainstormings diff --git a/test/mindwendel_web/controllers/brainstorming_controller_test.exs b/test/mindwendel_web/controllers/brainstorming_controller_test.exs index 296c0357..6f41bb4b 100644 --- a/test/mindwendel_web/controllers/brainstorming_controller_test.exs +++ b/test/mindwendel_web/controllers/brainstorming_controller_test.exs @@ -1,5 +1,5 @@ defmodule MindwendelWeb.BrainstormingControllerTest do - use MindwendelWeb.ConnCase + use MindwendelWeb.ConnCase, async: true import Ecto.Query diff --git a/test/mindwendel_web/controllers/file_controller_test.exs b/test/mindwendel_web/controllers/file_controller_test.exs index 19502ace..cc3ee1b1 100644 --- a/test/mindwendel_web/controllers/file_controller_test.exs +++ b/test/mindwendel_web/controllers/file_controller_test.exs @@ -1,5 +1,6 @@ defmodule MindwendelWeb.FileControllerTest do - use MindwendelWeb.ConnCase + use MindwendelWeb.ConnCase, async: true + alias Mindwendel.Services.Vault alias Mindwendel.Factory diff --git a/test/mindwendel_web/controllers/static_page_controller_test.exs b/test/mindwendel_web/controllers/static_page_controller_test.exs index 1c4d2e89..11411609 100644 --- a/test/mindwendel_web/controllers/static_page_controller_test.exs +++ b/test/mindwendel_web/controllers/static_page_controller_test.exs @@ -1,5 +1,5 @@ defmodule MindwendelWeb.StaticPageControllerTest do - use MindwendelWeb.ConnCase + use MindwendelWeb.ConnCase, async: true alias Mindwendel.Factory alias Mindwendel.Repo diff --git a/test/mindwendel_web/live/admin/brainstorming_live/edit_test.exs b/test/mindwendel_web/live/admin/brainstorming_live/edit_test.exs index 2b2d037c..ce89c6e2 100644 --- a/test/mindwendel_web/live/admin/brainstorming_live/edit_test.exs +++ b/test/mindwendel_web/live/admin/brainstorming_live/edit_test.exs @@ -1,5 +1,5 @@ defmodule MindwendelWeb.Admin.BrainstormingLive.EditTest do - use MindwendelWeb.ConnCase + use MindwendelWeb.ConnCase, async: true import Phoenix.LiveViewTest alias Mindwendel.Factory diff --git a/test/mindwendel_web/live/brainstorming_live/show_idea_delete_test.exs b/test/mindwendel_web/live/brainstorming_live/show_idea_delete_test.exs index 18023cde..17b2f763 100644 --- a/test/mindwendel_web/live/brainstorming_live/show_idea_delete_test.exs +++ b/test/mindwendel_web/live/brainstorming_live/show_idea_delete_test.exs @@ -1,5 +1,5 @@ defmodule MindwendelWeb.BrainstormingLive.ShowIdeaDeleteTest do - use MindwendelWeb.ConnCase + use MindwendelWeb.ConnCase, async: true import Phoenix.LiveViewTest alias Mindwendel.Brainstormings diff --git a/test/mindwendel_web/live/brainstorming_live/show_idea_edit_test.exs b/test/mindwendel_web/live/brainstorming_live/show_idea_edit_test.exs index 65bc150e..317f6b22 100644 --- a/test/mindwendel_web/live/brainstorming_live/show_idea_edit_test.exs +++ b/test/mindwendel_web/live/brainstorming_live/show_idea_edit_test.exs @@ -1,5 +1,5 @@ defmodule MindwendelWeb.BrainstormingLive.ShowIdeaEditTest do - use MindwendelWeb.ConnCase + use MindwendelWeb.ConnCase, async: true import Phoenix.LiveViewTest alias Mindwendel.Brainstormings alias Mindwendel.Accounts.User diff --git a/test/mindwendel_web/live/brainstorming_live/show_sort_by_label_test.exs b/test/mindwendel_web/live/brainstorming_live/show_sort_by_label_test.exs index 0e5046d8..5c95dad0 100644 --- a/test/mindwendel_web/live/brainstorming_live/show_sort_by_label_test.exs +++ b/test/mindwendel_web/live/brainstorming_live/show_sort_by_label_test.exs @@ -1,5 +1,5 @@ defmodule MindwendelWeb.BrainstormingLive.ShowSortByLabelTest do - use MindwendelWeb.ConnCase + use MindwendelWeb.ConnCase, async: true import Phoenix.LiveViewTest alias Mindwendel.Brainstormings diff --git a/test/mindwendel_web/live/brainstorming_live_test.exs b/test/mindwendel_web/live/brainstorming_live_test.exs index a27e260d..b385b395 100644 --- a/test/mindwendel_web/live/brainstorming_live_test.exs +++ b/test/mindwendel_web/live/brainstorming_live_test.exs @@ -1,5 +1,5 @@ defmodule MindwendelWeb.BrainstormingLiveTest do - use MindwendelWeb.ConnCase + use MindwendelWeb.ConnCase, async: true import Phoenix.LiveViewTest alias Mindwendel.Brainstormings diff --git a/test/mindwendel_web/live/label_live/captions_test.exs b/test/mindwendel_web/live/label_live/captions_test.exs index c4cc258f..0a205195 100644 --- a/test/mindwendel_web/live/label_live/captions_test.exs +++ b/test/mindwendel_web/live/label_live/captions_test.exs @@ -1,11 +1,13 @@ defmodule MindwendelWeb.LabelLive.CaptionsTest do - alias MindwendelWeb.LabelLive.CaptionsComponent - alias Mindwendel.Brainstormings - use MindwendelWeb.ConnCase + use MindwendelWeb.ConnCase, async: true + import Phoenix.LiveViewTest + alias Mindwendel.Brainstormings alias Mindwendel.Factory + alias MindwendelWeb.LabelLive.CaptionsComponent + setup do %{brainstorming: Factory.insert!(:brainstorming), user: Factory.insert!(:user)} end diff --git a/test/mindwendel_web/live/live_helpers_test.exs b/test/mindwendel_web/live/live_helpers_test.exs index f5149b9e..267e6436 100644 --- a/test/mindwendel_web/live/live_helpers_test.exs +++ b/test/mindwendel_web/live/live_helpers_test.exs @@ -1,5 +1,5 @@ defmodule MindwendelWeb.LiveHelpersTest do - use MindwendelWeb.ConnCase + use MindwendelWeb.ConnCase, async: true import Phoenix.LiveViewTest alias Mindwendel.Factory diff --git a/test/mindwendel_web/live/response_header_content_security_policy_test.exs b/test/mindwendel_web/live/response_header_content_security_policy_test.exs index 199430f6..90f2d557 100644 --- a/test/mindwendel_web/live/response_header_content_security_policy_test.exs +++ b/test/mindwendel_web/live/response_header_content_security_policy_test.exs @@ -1,5 +1,5 @@ defmodule MindwendelWeb.ResponseHeaderContentSecurityPolicyTest do - use MindwendelWeb.ConnCase + use MindwendelWeb.ConnCase, async: true alias Mindwendel.Factory diff --git a/test/repo/data_migrations/migrate_add_lanes_to_brainstormings_test.exs b/test/repo/data_migrations/migrate_add_lanes_to_brainstormings_test.exs index e2f20fc6..b19384a0 100644 --- a/test/repo/data_migrations/migrate_add_lanes_to_brainstormings_test.exs +++ b/test/repo/data_migrations/migrate_add_lanes_to_brainstormings_test.exs @@ -1,7 +1,7 @@ defmodule Mindwendel.Repo.DataMigrations.MigrateAddLanesToBrainstormingsTest do Code.require_file("./priv/repo/data_migrations/migrate_add_lanes_to_brainstormings.exs") - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true alias Mindwendel.Factory alias Mindwendel.Lanes alias Mindwendel.Repo.DataMigrations.MigrateAddLanesToBrainstormings diff --git a/test/repo/data_migrations/migrate_idea_labels_test.exs b/test/repo/data_migrations/migrate_idea_labels_test.exs index 672a2993..1262a5d0 100644 --- a/test/repo/data_migrations/migrate_idea_labels_test.exs +++ b/test/repo/data_migrations/migrate_idea_labels_test.exs @@ -1,7 +1,7 @@ defmodule Mindwendel.Repo.DataMigrations.MigrateIdealLabelsTest do Code.require_file("./priv/repo/data_migrations/migrate_idea_labels.exs") - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true alias Mindwendel.Factory alias Mindwendel.Repo alias Mindwendel.Brainstormings.Brainstorming diff --git a/test/repo/data_migrations/migrate_idea_labels_to_idea_idea_labels_test.exs b/test/repo/data_migrations/migrate_idea_labels_to_idea_idea_labels_test.exs index c23dce64..5f96ce5b 100644 --- a/test/repo/data_migrations/migrate_idea_labels_to_idea_idea_labels_test.exs +++ b/test/repo/data_migrations/migrate_idea_labels_to_idea_idea_labels_test.exs @@ -1,7 +1,7 @@ defmodule Mindwendel.Repo.DataMigrations.MigrateIdeaLabelsToIdeaIdeaLabelsTest do Code.require_file("./priv/repo/data_migrations/migrate_idea_labels_to_idea_idea_labels.exs") - use Mindwendel.DataCase + use Mindwendel.DataCase, async: true alias Mindwendel.Factory alias Mindwendel.Repo