Tests: Remove unneeded explicit cachex use.

Only use cachex when we're actually testing it.
origin/neckbeard
lain 2 years ago
parent c1129ff674
commit b4b68b71fc
  1. 4
      test/mix/tasks/pleroma/relay_test.exs
  2. 1
      test/pleroma/captcha_test.exs
  3. 2
      test/pleroma/user/query_test.exs
  4. 2
      test/pleroma/web/activity_pub/relay_test.exs
  5. 1
      test/pleroma/web/activity_pub/transmogrifier/delete_handling_test.exs
  6. 2
      test/pleroma/web/activity_pub/visibility_test.exs
  7. 4
      test/pleroma/web/admin_api/controllers/media_proxy_cache_controller_test.exs
  8. 2
      test/pleroma/web/mastodon_api/controllers/account_controller_test.exs
  9. 4
      test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
  10. 4
      test/pleroma/web/mastodon_api/views/status_view_test.exs
  11. 4
      test/pleroma/web/media_proxy/invalidation/http_test.exs
  12. 4
      test/pleroma/web/media_proxy/invalidation/script_test.exs
  13. 4
      test/pleroma/web/media_proxy/invalidation_test.exs
  14. 4
      test/pleroma/web/media_proxy/media_proxy_controller_test.exs
  15. 7
      test/pleroma/web/plugs/cache_test.exs
  16. 2
      test/pleroma/web/rich_media/parser/ttl/aws_signed_url_test.exs
  17. 6
      test/pleroma/web/twitter_api/twitter_api_test.exs

@ -100,7 +100,7 @@ defmodule Mix.Tasks.Pleroma.RelayTest do
end)
Pleroma.Repo.delete(user)
Cachex.clear(:user_cache)
User.invalidate_cache(user)
Mix.Tasks.Pleroma.Relay.run(["unfollow", target_instance])
@ -137,7 +137,7 @@ defmodule Mix.Tasks.Pleroma.RelayTest do
end)
Pleroma.Repo.delete(user)
Cachex.clear(:user_cache)
User.invalidate_cache(user)
Mix.Tasks.Pleroma.Relay.run(["unfollow", target_instance, "--force"])

@ -80,7 +80,6 @@ defmodule Pleroma.CaptchaTest do
assert is_binary(answer)
assert :ok = Captcha.validate(token, "63615261b77f5354fb8c4e4986477555", answer)
Cachex.del(:used_captcha_cache, token)
end
test "doesn't validate invalid answer" do

@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.User.QueryTest do
use Pleroma.DataCase, async: true
use Pleroma.DataCase
alias Pleroma.Repo
alias Pleroma.User

@ -84,7 +84,7 @@ defmodule Pleroma.Web.ActivityPub.RelayTest do
)
Pleroma.Repo.delete(user)
Cachex.clear(:user_cache)
User.invalidate_cache(user)
assert {:ok, %Activity{} = activity} = Relay.unfollow(user_ap_id, %{force: true})

@ -51,6 +51,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.DeleteHandlingTest do
Object.normalize(activity.data["object"])
|> Repo.delete()
# TODO: mock cachex
Cachex.del(:object_cache, "object:#{object.data["id"]}")
deleting_user = insert(:user)

@ -159,7 +159,7 @@ defmodule Pleroma.Web.ActivityPub.VisibilityTest do
user: user
} do
Repo.delete(user)
Cachex.clear(:user_cache)
Pleroma.User.invalidate_cache(user)
refute Visibility.is_private?(direct)
end

@ -12,10 +12,6 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do
setup do: clear_config([:media_proxy])
setup do
on_exit(fn -> Cachex.clear(:banned_urls_cache) end)
end
setup do
admin = insert(:user, is_admin: true)
token = insert(:oauth_admin_token, user: admin)

@ -1411,8 +1411,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|> json_response_and_validate_schema(:ok)
assert Token |> Repo.get_by(token: access_token) |> Repo.preload(:user) |> Map.get(:user)
Cachex.del(:used_captcha_cache, token)
end
test "returns 400 if any captcha field is not provided", %{conn: conn} do

@ -67,10 +67,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
"sensitive" => "0"
})
{:ok, ttl} = Cachex.ttl(:idempotency_cache, idempotency_key)
# Six hours
assert ttl > :timer.seconds(6 * 60 * 60 - 1)
assert %{"content" => "cofe", "id" => id, "spoiler_text" => "2hu", "sensitive" => false} =
json_response_and_validate_schema(conn_one, 200)

@ -160,7 +160,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
{:ok, activity} = CommonAPI.post(user, %{status: "Hey @shp!", visibility: "direct"})
Repo.delete(user)
Cachex.clear(:user_cache)
User.invalidate_cache(user)
finger_url =
"https://localhost/.well-known/webfinger?resource=acct:#{user.nickname}@localhost"
@ -194,7 +194,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|> Ecto.Changeset.change(%{ap_id: "#{user.ap_id}/extension/#{user.nickname}"})
|> Repo.update()
Cachex.clear(:user_cache)
User.invalidate_cache(user)
result = StatusView.render("show.json", activity: activity)

@ -9,10 +9,6 @@ defmodule Pleroma.Web.MediaProxy.Invalidation.HttpTest do
import ExUnit.CaptureLog
import Tesla.Mock
setup do
on_exit(fn -> Cachex.clear(:banned_urls_cache) end)
end
test "logs hasn't error message when request is valid" do
mock(fn
%{method: :purge, url: "http://example.com/media/example.jpg"} ->

@ -8,10 +8,6 @@ defmodule Pleroma.Web.MediaProxy.Invalidation.ScriptTest do
import ExUnit.CaptureLog
setup do
on_exit(fn -> Cachex.clear(:banned_urls_cache) end)
end
test "it logger error when script not found" do
assert capture_log(fn ->
assert Invalidation.Script.purge(

@ -15,10 +15,6 @@ defmodule Pleroma.Web.MediaProxy.InvalidationTest do
setup do: clear_config([:media_proxy])
setup do
on_exit(fn -> Cachex.clear(:banned_urls_cache) end)
end
describe "Invalidation.Http" do
test "perform request to clear cache" do
Config.put([:media_proxy, :enabled], false)

@ -10,10 +10,6 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyControllerTest do
alias Pleroma.Web.MediaProxy
alias Plug.Conn
setup do
on_exit(fn -> Cachex.clear(:banned_urls_cache) end)
end
describe "Media Proxy" do
setup do
clear_config([:media_proxy, :enabled], true)

@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Plugs.CacheTest do
use ExUnit.Case, async: true
use Pleroma.DataCase
use Plug.Test
alias Pleroma.Web.Plugs.Cache
@ -24,11 +24,6 @@ defmodule Pleroma.Web.Plugs.CacheTest do
@ttl 5
setup do
Cachex.clear(:web_resp_cache)
:ok
end
test "caches a response" do
assert @miss_resp ==
conn(:get, "/")

@ -3,7 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrlTest do
use ExUnit.Case, async: true
use Pleroma.DataCase
test "s3 signed url is parsed correct for expiration time" do
url = "https://pleroma.social/amz"

@ -423,10 +423,4 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
assert is_binary(error)
refute User.get_cached_by_nickname("lain")
end
setup do
Supervisor.terminate_child(Pleroma.Supervisor, Cachex)
Supervisor.restart_child(Pleroma.Supervisor, Cachex)
:ok
end
end

Loading…
Cancel
Save