forked from MarathonLabs/marathon
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sergey Chelombitko
committed
Dec 17, 2024
1 parent
bfdfcb0
commit a8e0080
Showing
8 changed files
with
250 additions
and
268 deletions.
There are no files selected for viewing
60 changes: 0 additions & 60 deletions
60
.../integrationTest/kotlin/com/malinskiy/marathon/cache/gradle/GradleHttpCacheServiceSpek.kt
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
.../integrationTest/kotlin/com/malinskiy/marathon/cache/gradle/GradleHttpCacheServiceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.malinskiy.marathon.cache.gradle | ||
|
||
import com.malinskiy.marathon.cache.SimpleCacheKey | ||
import com.malinskiy.marathon.cache.SimpleEntryReader | ||
import com.malinskiy.marathon.cache.SimpleEntryWriter | ||
import com.malinskiy.marathon.cache.config.RemoteCacheConfiguration | ||
import kotlinx.coroutines.test.runTest | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Assertions.assertFalse | ||
import org.junit.jupiter.api.Assertions.assertTrue | ||
import org.junit.jupiter.api.AutoClose | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
|
||
class GradleHttpCacheServiceTest { | ||
@AutoClose | ||
private val container = GradleCacheContainer() | ||
|
||
@AutoClose | ||
private lateinit var cacheService: GradleHttpCacheService | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
container.start() | ||
cacheService = GradleHttpCacheService(RemoteCacheConfiguration.Enabled(container.cacheUrl)) | ||
} | ||
|
||
@Test | ||
fun `GIVEN empty cache WHEN loading an entry from cache THEN returns false`() = runTest { | ||
val cacheKey = SimpleCacheKey("this_key_does_not_exists") | ||
|
||
val reader = SimpleEntryReader() | ||
val result = cacheService.load(cacheKey, reader) | ||
|
||
assertFalse(result) | ||
assertFalse(reader.readInvoked) | ||
} | ||
|
||
@Test | ||
fun `GIVEN cache with an entry WHEN loading the entry from cache THEN returns the original data`() = runTest { | ||
val cacheKey = SimpleCacheKey("test") | ||
cacheService.store(cacheKey, SimpleEntryWriter("qwerty")) | ||
|
||
val reader = SimpleEntryReader() | ||
val result = cacheService.load(cacheKey, reader) | ||
|
||
assertTrue(result) | ||
assertTrue(reader.readInvoked) | ||
assertEquals("qwerty", reader.data) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.