Skip to content

Commit

Permalink
JT-78303: Add remove test
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-zatsepin committed Jan 16, 2024
1 parent c716585 commit bc5264c
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ class CaffeinePersistentCacheTest {
assertEquals("value2", cache.get("key2"))
}

@Test
fun `should remove entry`() {
// Given
val cache = givenSizedCache(2)
cache.put("key1", "value1")
cache.put("key2", "value2")

// When
cache.remove("key1")

// Then
assertEquals(null, cache.get("key1"))
assertEquals("value2", cache.get("key2"))
assertEquals(1, cache.count())
}

@Test
fun `should evict`() {
// Given
Expand Down Expand Up @@ -172,7 +188,7 @@ class CaffeinePersistentCacheTest {

private fun givenSizedCache(size: Long): CaffeinePersistentCache<String, String> {
val config = CaffeineCacheConfig<String>(
sizeEviction = SizedEviction(size),
sizeEviction = WeightedEviction(size) { 1 },
directExecution = true
)
return CaffeinePersistentCache.create(config)
Expand Down

0 comments on commit bc5264c

Please sign in to comment.