From 74579115a73d697aed67abe2dc8ea1a664c89c5b Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Mon, 11 Feb 2019 00:08:48 +0100 Subject: [PATCH] =?UTF-8?q?test:=20Change=20`lenght(=E2=80=A6)=20=3D=3D=20?= =?UTF-8?q?0`=20to=20`Enum.empty=3F(=E2=80=A6)`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/formatter_test.exs | 2 +- test/notification_test.exs | 30 +++++++++---------- test/tasks/user_test.exs | 2 +- .../mastodon_api_controller_test.exs | 2 +- test/web/websub/websub_controller_test.exs | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/test/formatter_test.exs b/test/formatter_test.exs index 2e717194b..f14077d25 100644 --- a/test/formatter_test.exs +++ b/test/formatter_test.exs @@ -197,7 +197,7 @@ test "does not give a replacement for single-character local nicknames who don't {subs, text} = Formatter.add_user_links({[], text}, mentions) - assert length(subs) == 0 + assert Enum.empty?(subs) Enum.each(subs, fn {uuid, _} -> assert String.contains?(text, uuid) end) expected_text = "@a hi" diff --git a/test/notification_test.exs b/test/notification_test.exs index d36a92a7c..755874a3d 100644 --- a/test/notification_test.exs +++ b/test/notification_test.exs @@ -300,7 +300,7 @@ test "liking an activity results in 1 notification, then 0 if the activity is de {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"}) - assert length(Notification.for_user(user)) == 0 + assert Enum.empty?(Notification.for_user(user)) {:ok, _, _} = CommonAPI.favorite(activity.id, other_user) @@ -308,7 +308,7 @@ test "liking an activity results in 1 notification, then 0 if the activity is de {:ok, _} = CommonAPI.delete(activity.id, user) - assert length(Notification.for_user(user)) == 0 + assert Enum.empty?(Notification.for_user(user)) end test "liking an activity results in 1 notification, then 0 if the activity is unliked" do @@ -317,7 +317,7 @@ test "liking an activity results in 1 notification, then 0 if the activity is un {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"}) - assert length(Notification.for_user(user)) == 0 + assert Enum.empty?(Notification.for_user(user)) {:ok, _, _} = CommonAPI.favorite(activity.id, other_user) @@ -325,7 +325,7 @@ test "liking an activity results in 1 notification, then 0 if the activity is un {:ok, _, _, _} = CommonAPI.unfavorite(activity.id, other_user) - assert length(Notification.for_user(user)) == 0 + assert Enum.empty?(Notification.for_user(user)) end test "repeating an activity results in 1 notification, then 0 if the activity is deleted" do @@ -334,7 +334,7 @@ test "repeating an activity results in 1 notification, then 0 if the activity is {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"}) - assert length(Notification.for_user(user)) == 0 + assert Enum.empty?(Notification.for_user(user)) {:ok, _, _} = CommonAPI.repeat(activity.id, other_user) @@ -342,7 +342,7 @@ test "repeating an activity results in 1 notification, then 0 if the activity is {:ok, _} = CommonAPI.delete(activity.id, user) - assert length(Notification.for_user(user)) == 0 + assert Enum.empty?(Notification.for_user(user)) end test "repeating an activity results in 1 notification, then 0 if the activity is unrepeated" do @@ -351,7 +351,7 @@ test "repeating an activity results in 1 notification, then 0 if the activity is {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"}) - assert length(Notification.for_user(user)) == 0 + assert Enum.empty?(Notification.for_user(user)) {:ok, _, _} = CommonAPI.repeat(activity.id, other_user) @@ -359,7 +359,7 @@ test "repeating an activity results in 1 notification, then 0 if the activity is {:ok, _, _} = CommonAPI.unrepeat(activity.id, other_user) - assert length(Notification.for_user(user)) == 0 + assert Enum.empty?(Notification.for_user(user)) end test "liking an activity which is already deleted does not generate a notification" do @@ -368,15 +368,15 @@ test "liking an activity which is already deleted does not generate a notificati {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"}) - assert length(Notification.for_user(user)) == 0 + assert Enum.empty?(Notification.for_user(user)) {:ok, _deletion_activity} = CommonAPI.delete(activity.id, user) - assert length(Notification.for_user(user)) == 0 + assert Enum.empty?(Notification.for_user(user)) {:error, _} = CommonAPI.favorite(activity.id, other_user) - assert length(Notification.for_user(user)) == 0 + assert Enum.empty?(Notification.for_user(user)) end test "repeating an activity which is already deleted does not generate a notification" do @@ -385,15 +385,15 @@ test "repeating an activity which is already deleted does not generate a notific {:ok, activity} = CommonAPI.post(user, %{"status" => "test post"}) - assert length(Notification.for_user(user)) == 0 + assert Enum.empty?(Notification.for_user(user)) {:ok, _deletion_activity} = CommonAPI.delete(activity.id, user) - assert length(Notification.for_user(user)) == 0 + assert Enum.empty?(Notification.for_user(user)) {:error, _} = CommonAPI.repeat(activity.id, other_user) - assert length(Notification.for_user(user)) == 0 + assert Enum.empty?(Notification.for_user(user)) end test "replying to a deleted post without tagging does not generate a notification" do @@ -409,7 +409,7 @@ test "replying to a deleted post without tagging does not generate a notificatio "in_reply_to_status_id" => activity.id }) - assert length(Notification.for_user(user)) == 0 + assert Enum.empty?(Notification.for_user(user)) end end end diff --git a/test/tasks/user_test.exs b/test/tasks/user_test.exs index 44271898c..7b814d171 100644 --- a/test/tasks/user_test.exs +++ b/test/tasks/user_test.exs @@ -151,7 +151,7 @@ test "user is unsubscribed" do assert message =~ "Successfully unsubscribed" user = User.get_by_nickname(user.nickname) - assert length(user.following) == 0 + assert Enum.empty?(user.following) assert user.info.deactivated end diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 9fd505f84..19393f355 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -36,7 +36,7 @@ test "the home timeline", %{conn: conn} do |> assign(:user, user) |> get("/api/v1/timelines/home") - assert length(json_response(conn, 200)) == 0 + assert Enum.empty?(json_response(conn, 200)) {:ok, user} = User.follow(user, following) diff --git a/test/web/websub/websub_controller_test.exs b/test/web/websub/websub_controller_test.exs index 04fb4a5a3..87b01d89b 100644 --- a/test/web/websub/websub_controller_test.exs +++ b/test/web/websub/websub_controller_test.exs @@ -81,7 +81,7 @@ test "rejects incoming feed updates with the wrong signature", %{conn: conn} do assert response(conn, 500) == "Error" - assert length(Repo.all(Activity)) == 0 + assert Enum.empty?(Repo.all(Activity)) end end end