Skip to content

Commit be9e261

Browse files
committed
✅ Increase coverage
1 parent de7efc4 commit be9e261

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/main/kotlin/io/github/tobi/laa/spring/boot/embedded/redis/conf/RedisConfLocator.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal object RedisConfLocator {
1818
@Suppress("UNCHECKED_CAST")
1919
internal fun locate(server: Redis): Path {
2020
val args = ARGS_PROP[server as RedisInstance] as List<String>
21-
return args.find { it.endsWith(".conf") }?.let { Paths.get(it) }
22-
?: throw IllegalStateException("No config file found for embedded Redis server: $server")
21+
val redisConf = args.find { it.endsWith(".conf") }?.let { Paths.get(it) }
22+
return redisConf ?: throw IllegalStateException("No config file found for embedded Redis server: $server")
2323
}
2424
}

src/test/kotlin/io/github/tobi/laa/spring/boot/embedded/redis/conf/RedisConfLocatorTest.kt

+9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package io.github.tobi.laa.spring.boot.embedded.redis.conf
22

33
import io.mockk.junit5.MockKExtension
4+
import org.assertj.core.api.Assertions.assertThat
45
import org.assertj.core.api.Assertions.assertThatThrownBy
56
import org.junit.jupiter.api.DisplayName
67
import org.junit.jupiter.api.Test
78
import org.junit.jupiter.api.extension.ExtendWith
89
import redis.embedded.RedisInstance
10+
import java.nio.file.Paths
911

1012
@DisplayName("Tests for RedisConfLocator")
1113
@ExtendWith(MockKExtension::class)
@@ -29,6 +31,13 @@ internal class RedisConfLocatorTest {
2931
.hasMessage("No config file found for embedded Redis server: $redis")
3032
}
3133

34+
@Test
35+
@DisplayName("RedisConfLocator should return path to redis.conf file if it exists")
36+
fun redisConfFound_shouldReturnPath() {
37+
val redis = TestRedis(listOf("redis.conf"))
38+
assertThat(RedisConfLocator.locate(redis)).isEqualTo(Paths.get("redis.conf"))
39+
}
40+
3241
private class TestRedis(args: List<String>) : RedisInstance(0, args, null, false, null, null) {
3342

3443
override fun start() {}

0 commit comments

Comments
 (0)