Only use cachex when we're actually testing it.
end)
Pleroma.Repo.delete(user)
- Cachex.clear(:user_cache)
+ User.invalidate_cache(user)
Mix.Tasks.Pleroma.Relay.run(["unfollow", target_instance])
end)
Pleroma.Repo.delete(user)
- Cachex.clear(:user_cache)
+ User.invalidate_cache(user)
Mix.Tasks.Pleroma.Relay.run(["unfollow", target_instance, "--force"])
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
# 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
)
Pleroma.Repo.delete(user)
- Cachex.clear(:user_cache)
+ User.invalidate_cache(user)
assert {:ok, %Activity{} = activity} = Relay.unfollow(user_ap_id, %{force: true})
Object.normalize(activity.data["object"])
|> Repo.delete()
+ # TODO: mock cachex
Cachex.del(:object_cache, "object:#{object.data["id"]}")
deleting_user = insert(:user)
user: user
} do
Repo.delete(user)
- Cachex.clear(:user_cache)
+ Pleroma.User.invalidate_cache(user)
refute Visibility.is_private?(direct)
end
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)
|> 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
"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)
{: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"
|> 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)
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"} ->
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(
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)
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)
# 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
@ttl 5
- setup do
- Cachex.clear(:web_resp_cache)
- :ok
- end
-
test "caches a response" do
assert @miss_resp ==
conn(:get, "/")
# 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"
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