mirror of
https://git.pleroma.social/sjw/pleroma.git
synced 2024-12-25 09:56:17 +01:00
tests: add tests for User + cache interactions
This commit is contained in:
parent
f584a603f9
commit
21dafa7cd0
@ -551,4 +551,31 @@ defmodule Pleroma.UserTest do
|
|||||||
assert Pleroma.HTML.Scrubber.TwitterText == User.html_filter_policy(user)
|
assert Pleroma.HTML.Scrubber.TwitterText == User.html_filter_policy(user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "caching" do
|
||||||
|
test "invalidate_cache works" do
|
||||||
|
user = insert(:user)
|
||||||
|
user_info = User.get_cached_user_info(user)
|
||||||
|
|
||||||
|
User.invalidate_cache(user)
|
||||||
|
|
||||||
|
{:ok, nil} = Cachex.get(:user_cache, "ap_id:#{user.ap_id}")
|
||||||
|
{:ok, nil} = Cachex.get(:user_cache, "nickname:#{user.nickname}")
|
||||||
|
{:ok, nil} = Cachex.get(:user_cache, "user_info:#{user.id}")
|
||||||
|
end
|
||||||
|
|
||||||
|
test "User.delete() plugs any possible zombie objects" do
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
|
{:ok, _} = User.delete(user)
|
||||||
|
|
||||||
|
{:ok, cached_user} = Cachex.get(:user_cache, "ap_id:#{user.ap_id}")
|
||||||
|
|
||||||
|
assert cached_user != user
|
||||||
|
|
||||||
|
{:ok, cached_user} = Cachex.get(:user_cache, "nickname:#{user.ap_id}")
|
||||||
|
|
||||||
|
assert cached_user != user
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user