Skip to content

Commit

Permalink
Add a simple test for clearing caches
Browse files Browse the repository at this point in the history
  • Loading branch information
geekingfrog committed Jul 1, 2024
1 parent 8cc544e commit f543bcc
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/teiserver/caches_test.exs
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

0 comments on commit f543bcc

Please sign in to comment.