-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple test for clearing caches
- Loading branch information
1 parent
8cc544e
commit dedf5a4
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
defmodule Teiserver.CachesTest do | ||
use Teiserver.DataCase, async: false | ||
|
||
# This module is merely here to check that | ||
# Teiserver.TeiserverTestLib.clear_all_con_caches does indeed clear the advertised | ||
# cache across tests. | ||
# because all queries rely heavily on caches, it's important to clear them between | ||
# tests so as not to pollute other tests | ||
|
||
test "Clear user caches 1" do | ||
name = "ClearDbEachTestUser" | ||
assert is_nil(Teiserver.CacheUser.get_user_by_name(name)) | ||
user = Teiserver.TeiserverTestLib.new_user(name) | ||
result = Teiserver.CacheUser.get_user_by_id(user.id) | ||
assert result[:name] == name | ||
end | ||
|
||
test "Clear user caches 2" do | ||
name = "ClearDbEachTestUser" | ||
assert is_nil(Teiserver.CacheUser.get_user_by_name(name)) | ||
user = Teiserver.TeiserverTestLib.new_user(name) | ||
result = Teiserver.CacheUser.get_user_by_id(user.id) | ||
assert result[:name] == name | ||
end | ||
end |