refactor: fix error when template cache is set to 0 (#980)

This commit is contained in:
Juro Oravec 2025-02-16 21:06:33 +01:00 committed by GitHub
parent 58d4c78671
commit fdfdc72ed2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 0 deletions

View file

@ -43,6 +43,27 @@ class CacheTests(TestCase):
self.assertEqual(cache.get("e"), None)
self.assertEqual(cache.get("f"), None)
def test_cache_maxsize_zero(self):
cache = LRUCache[int](maxsize=0)
cache.set("a", 1)
self.assertEqual(cache.get("a"), None)
cache.set("b", 2)
cache.set("c", 3)
self.assertEqual(cache.get("b"), None)
self.assertEqual(cache.get("c"), None)
# Same with negative numbers
cache = LRUCache[int](maxsize=-1)
cache.set("a", 1)
self.assertEqual(cache.get("a"), None)
cache.set("b", 2)
cache.set("c", 3)
self.assertEqual(cache.get("b"), None)
self.assertEqual(cache.get("c"), None)
class ComponentMediaCacheTests(TestCase):
def setUp(self):