File tree Expand file tree Collapse file tree 5 files changed +18
-8
lines changed
commonMain/kotlin/com/algolia/search/transport/internal Expand file tree Collapse file tree 5 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -10,20 +10,22 @@ internal val ApplicationID.searchHosts
1010 get() = listOf (
1111 RetryableHost (" $this -dsn.algolia.net" , CallType .Read ),
1212 RetryableHost (" $this .algolia.net" , CallType .Write ),
13+ ) + mutableListOf (
1314 RetryableHost (" $this -1.algolianet.com" ),
1415 RetryableHost (" $this -2.algolianet.com" ),
1516 RetryableHost (" $this -3.algolianet.com" )
16- )
17+ ). apply { shuffle() }
1718
1819internal val insightHosts = listOf (RetryableHost (" insights.algolia.io" ))
1920internal val Region .Analytics .hosts get() = listOf (RetryableHost (" analytics.$this .algolia.com" ))
2021internal val Region .Personalization .hosts get() = listOf (RetryableHost (" personalization.$this .algolia.com" ))
2122internal val placesHosts = listOf (
2223 RetryableHost (" places-dsn.algolia.net" ),
24+ ) + mutableListOf (
2325 RetryableHost (" places-1.algolianet.com" ),
2426 RetryableHost (" places-2.algolianet.com" ),
2527 RetryableHost (" places-3.algolianet.com" )
26- )
28+ ). apply { shuffle() }
2729
2830@PublishedApi
2931internal fun RetryableHost.reset () {
Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ internal infix fun <T> Collection<T>?.shouldNotContain(element: T) {
3838 (this ?.contains(element) ? : false ).shouldBeFalse()
3939}
4040
41+ internal infix fun <T > Collection<T>?.shouldContainAll (collection : Collection <T >) {
42+ (this ?.containsAll(collection) ? : false ).shouldBeTrue()
43+ }
44+
4145internal fun <T > Collection<T>.shouldBeEmpty () {
4246 this .isEmpty().shouldBeTrue()
4347}
@@ -77,3 +81,4 @@ internal inline fun <reified T : Throwable> shouldFailWith(noinline block: suspe
7781 }
7882 }
7983}
84+
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import io.ktor.client.features.logging.LogLevel
2020import shouldBeNull
2121import shouldEqual
2222import kotlin.test.Test
23+ import shouldContainAll
2324
2425internal class TestConfiguration {
2526
@@ -39,7 +40,7 @@ internal class TestConfiguration {
3940 writeTimeout shouldEqual DEFAULT_WRITE_TIMEOUT
4041 readTimeout shouldEqual DEFAULT_READ_TIMEOUT
4142 logLevel shouldEqual LogLevel .NONE
42- hosts shouldEqual applicationID.searchHosts
43+ hosts shouldContainAll applicationID.searchHosts
4344 defaultHeaders.shouldBeNull()
4445 engine.shouldBeNull()
4546 httpClientConfig.shouldBeNull()
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import com.algolia.search.transport.internal.Transport
88import runBlocking
99import shouldEqual
1010import kotlin.test.Test
11+ import shouldContainAll
1112
1213internal class TestCallableHosts {
1314
@@ -24,7 +25,7 @@ internal class TestCallableHosts {
2425 runBlocking {
2526 val hosts = transport.callableHosts(CallType .Read )
2627
27- hosts shouldEqual listOf (
28+ hosts shouldContainAll listOf (
2829 hostRead,
2930 hostFallback1,
3031 hostFallback2,
@@ -38,7 +39,7 @@ internal class TestCallableHosts {
3839 runBlocking {
3940 val hosts = transport.callableHosts(CallType .Write )
4041
41- hosts shouldEqual listOf (
42+ hosts shouldContainAll listOf (
4243 hostWrite,
4344 hostFallback1,
4445 hostFallback2,
@@ -67,7 +68,7 @@ internal class TestCallableHosts {
6768
6869 val hosts = transport.callableHosts(CallType .Read )
6970
70- hosts shouldEqual listOf (hostfallback3 )
71+ hosts shouldEqual listOf (transport.hosts.last() )
7172 }
7273 }
7374
@@ -78,7 +79,7 @@ internal class TestCallableHosts {
7879
7980 val hosts = transport.callableHosts(CallType .Write )
8081
81- hosts shouldEqual listOf (
82+ hosts shouldContainAll listOf (
8283 hostWrite,
8384 hostFallback1,
8485 hostFallback2,
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import com.algolia.search.transport.internal.reset
99import com.algolia.search.transport.internal.searchHosts
1010import shouldEqual
1111import kotlin.test.Test
12+ import shouldContainAll
1213
1314internal class TestRetryableHost {
1415
@@ -17,7 +18,7 @@ internal class TestRetryableHost {
1718
1819 @Test
1920 fun searchHosts () {
20- applicationID.searchHosts shouldEqual listOf (
21+ applicationID.searchHosts shouldContainAll listOf (
2122 RetryableHost (" $applicationID -dsn.algolia.net" , CallType .Read ),
2223 RetryableHost (" $applicationID .algolia.net" , CallType .Write ),
2324 RetryableHost (" $applicationID -1.algolianet.com" ),
You can’t perform that action at this time.
0 commit comments