Skip to content

Commit

Permalink
refactor(github-config): Simplify overriding configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Nov 14, 2024
1 parent ad94c3e commit 05c2401
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions config/github/src/test/kotlin/GitHubConfigFileProviderTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ class GitHubConfigFileProviderTest : WordSpec({
setLastModified(outdatedModifiedTime)
}

val cacheConfig = mapOf(CACHE_DIRECTORY to cacheDir.absolutePath)

val provider = getProvider(cacheConfig)
val provider = getProvider(CACHE_DIRECTORY to cacheDir.absolutePath)
provider.resolveContext(Context(REVISION))

oldRevisionDir shouldNot exist()
Expand All @@ -172,9 +170,7 @@ class GitHubConfigFileProviderTest : WordSpec({
setLastModified(outdatedModifiedTime)
}

val cacheConfig = mapOf(CACHE_DIRECTORY to cacheDir.absolutePath)

val provider = getProvider(cacheConfig)
val provider = getProvider(CACHE_DIRECTORY to cacheDir.absolutePath)
provider.resolveContext(Context(revision))

oldRevisionDir shouldBe aDirectory()
Expand All @@ -197,9 +193,8 @@ class GitHubConfigFileProviderTest : WordSpec({
"use caching when configured" {
server.stubRawFile()
val cacheDir = tempdir()
val cacheConfig = mapOf(CACHE_DIRECTORY to cacheDir.absolutePath)

val provider = getProvider(cacheConfig)
val provider = getProvider(CACHE_DIRECTORY to cacheDir.absolutePath)
provider.getFile(Context(REVISION), Path(CONFIG_PATH)).close()

val fileContent = provider.getFile(Context(REVISION), Path(CONFIG_PATH))
Expand Down Expand Up @@ -317,9 +312,8 @@ class GitHubConfigFileProviderTest : WordSpec({
val expectedPaths = setOf(Path(CONFIG_PATH + "1"), Path(CONFIG_PATH + "2"))

val cacheDir = tempdir()
val cacheConfig = mapOf(CACHE_DIRECTORY to cacheDir.absolutePath)

val provider = getProvider(cacheConfig)
val provider = getProvider(CACHE_DIRECTORY to cacheDir.absolutePath)
provider.listFiles(Context(REVISION), Path(DIRECTORY_PATH))

val listFiles = provider.listFiles(Context(REVISION), Path(DIRECTORY_PATH))
Expand Down Expand Up @@ -399,7 +393,7 @@ internal const val API_TOKEN = "test-api-token"
/**
* Return a [GitHubConfigFileProvider] instance with a default configuration and optional additional [properties].
*/
private fun getProvider(properties: Map<String, String> = emptyMap()): GitHubConfigFileProvider {
private fun getProvider(vararg properties: Pair<String, String>): GitHubConfigFileProvider {
val secretProvider = mockk<ConfigSecretProvider>()

every { secretProvider.getSecret(TOKEN) } returns API_TOKEN
Expand Down

0 comments on commit 05c2401

Please sign in to comment.