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 dedf5a4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/teiserver/caches_test.exs
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

0 comments on commit dedf5a4

Please sign in to comment.