forked from AkkomaGang/akkoma
tests: add tests for User + cache interactions
This commit is contained in:
parent
f584a603f9
commit
21dafa7cd0
1 changed files with 27 additions and 0 deletions
|
@ -551,4 +551,31 @@ test "html_filter_policy returns TwitterText scrubber when rich-text is disabled
|
||||||
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 a new issue