summary refs log tree commit diff
path: root/tests/util/test_lrucache.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2021-04-02 11:28:51 +0100
committerErik Johnston <erik@matrix.org>2021-04-02 11:28:51 +0100
commite2b2decd1177654867f46cdb11529fbb1f5a4f30 (patch)
treebc0054234567fc209ba83de3c27c3f285e7c9ed1 /tests/util/test_lrucache.py
parentfix (diff)
downloadsynapse-e2b2decd1177654867f46cdb11529fbb1f5a4f30.tar.xz
Diffstat (limited to 'tests/util/test_lrucache.py')
-rw-r--r--tests/util/test_lrucache.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/util/test_lrucache.py b/tests/util/test_lrucache.py
index a739a6aaaf..dd8c46ee49 100644
--- a/tests/util/test_lrucache.py
+++ b/tests/util/test_lrucache.py
@@ -30,6 +30,23 @@ class LruCacheTestCase(unittest.HomeserverTestCase):
         self.assertEquals(cache.get("key"), "value")
         self.assertEquals(cache["key"], "value")
 
+    def test_time_evict(self):
+        self.reactor.advance(100 * 60)
+
+        cache = LruCache(100, reactor=self.reactor)
+        cache["key"] = "value"
+        cache["key2"] = "value2"
+
+        cache._on_resize()
+        self.assertEquals(cache.get("key"), "value")
+
+        self.reactor.advance(20 * 60)
+
+        print(self.reactor.seconds())
+
+        cache._on_resize()
+        self.assertEquals(cache.get("key"), None)
+
     def test_eviction(self):
         cache = LruCache(2)
         cache[1] = 1