-
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 f543bcc
Showing
1 changed file
with
42 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,42 @@ | ||
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 | ||
|
||
@caches [ | ||
:telemetry_complex_client_event_types_cache, | ||
:telemetry_complex_lobby_event_types_cache, | ||
:telemetry_complex_match_event_types_cache, | ||
:telemetry_complex_server_event_types_cache, | ||
:telemetry_property_types_cache, | ||
:telemetry_simple_client_event_types_cache, | ||
:telemetry_simple_lobby_event_types_cache, | ||
:telemetry_simple_match_event_types_cache, | ||
:telemetry_simple_server_event_types_cache, | ||
:users, | ||
:users_lookup_id_with_discord, | ||
:users_lookup_id_with_email, | ||
:users_lookup_id_with_name, | ||
:users_lookup_name_with_id | ||
] | ||
|
||
test "clear caches between tests 1" do | ||
for cache <- @caches do | ||
assert is_nil(ConCache.get(cache, "test_key")) | ||
ConCache.put(cache, "test_key", "test_val") | ||
assert "test_val" == ConCache.get(cache, "test_key") | ||
end | ||
end | ||
|
||
test "clear caches between tests 2" do | ||
for cache <- @caches do | ||
assert is_nil(ConCache.get(cache, "test_key")) | ||
ConCache.put(cache, "test_key", "test_val") | ||
assert "test_val" == ConCache.get(cache, "test_key") | ||
end | ||
end | ||
end |