You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/kotlin/io/github/tobi/laa/spring/boot/embedded/redis/highavailability/RedisHighAvailabilityContextCustomizer.kt
+26-22Lines changed: 26 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -36,47 +36,52 @@ internal class RedisHighAvailabilityContextCustomizer(
36
36
privateval manuallySpecifiedPorts =
37
37
config.ports.filter { it !=0 }.toSet() + config.sentinels.map { it.port }.filter { it !=0 }.toSet()
38
38
privateval name = config.name.ifEmpty { BirdNameProvider.next() }.replace(Regex("[^a-zA-Z0-9]"), "")
39
-
privatelateinitvar nodeProvider:NodeProvider
39
+
privatevar nodeProvider:NodeProvider?=null
40
40
privateval customizer = config.customizer.map { c -> c.createInstance() }.toList()
Copy file name to clipboardExpand all lines: src/test/kotlin/io/github/tobi/laa/spring/boot/embedded/redis/highavailability/RedisHighAvailabilityContextCustomizerTest.kt
+21-1Lines changed: 21 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -58,7 +58,7 @@ internal class RedisHighAvailabilityContextCustomizerTest {
58
58
59
59
@Test
60
60
@DisplayName("RedisHighAvailabilityContextCustomizer should throw NoSuchElementException when no nodes are available")
61
-
funnoMoreNodes_shouldThrow() {
61
+
funnoNodes_shouldThrow() {
62
62
mockkConstructor(NodeProvider::class) {
63
63
every { anyConstructed<NodeProvider>().next() } throws NoSuchElementException()
64
64
assertThatThrownBy {
@@ -73,6 +73,26 @@ internal class RedisHighAvailabilityContextCustomizerTest {
73
73
}
74
74
}
75
75
76
+
@Test
77
+
@DisplayName("RedisHighAvailabilityContextCustomizer should throw NoSuchElementException when not enough nodes are available")
78
+
funnotEnoughNodes_shouldThrow() {
79
+
mockkConstructor(NodeProvider::class) {
80
+
every { anyConstructed<NodeProvider>().next() } returns Node(
0 commit comments