Skip to content

Commit 77e855c

Browse files
authored
Test: remove flake (#5167)
* Speed up tests * revert native-benchmarks
1 parent b141b76 commit 77e855c

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

tests/integration-tests/src/appleTest/kotlin/test/HttpEngineTest.kt

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ import com.apollographql.apollo3.mpp.currentTimeMillis
99
import com.apollographql.apollo3.network.http.DefaultHttpEngine
1010
import com.apollographql.apollo3.network.http.get
1111
import com.apollographql.apollo3.testing.internal.runTest
12-
import platform.CFNetwork.kCFErrorDomainCFNetwork
13-
import platform.CFNetwork.kCFErrorHTTPSProxyConnectionFailure
14-
import platform.Foundation.CFBridgingRelease
1512
import platform.Foundation.NSError
16-
import platform.Foundation.NSURLErrorCannotFindHost
13+
import platform.Foundation.NSURLErrorCannotConnectToHost
1714
import platform.Foundation.NSURLErrorDomain
1815
import platform.Foundation.NSURLErrorTimedOut
1916
import kotlin.test.Test
@@ -26,7 +23,11 @@ import kotlin.test.fail
2623
class HttpEngineTest {
2724
@Test
2825
fun canReadNSError() = runTest {
29-
val apolloClient = ApolloClient.Builder().serverUrl("https://inexistent.host/graphql").build()
26+
/**
27+
* Try to trigger an error wihtout having to wait 60s on a timeout.
28+
* Hopefully Port 1 is closed on most machines. If that's not enough, we'd need to find an instrumented server
29+
*/
30+
val apolloClient = ApolloClient.Builder().serverUrl("https://127.0.0.1:1/graphql").build()
3031

3132
val response = apolloClient.query(HeroNameQuery()).execute()
3233
val apolloNetworkException = response.exception
@@ -38,15 +39,8 @@ class HttpEngineTest {
3839
// assertIs<NSError>(cause)
3940
check(cause is NSError)
4041

41-
assertTrue(
42-
when {
43-
// Happens locally if a proxy is running
44-
cause.domain == (CFBridgingRelease(kCFErrorDomainCFNetwork) as String) && cause.code == kCFErrorHTTPSProxyConnectionFailure.toLong() -> true
45-
// Default case
46-
cause.domain == NSURLErrorDomain && cause.code == NSURLErrorCannotFindHost -> true
47-
else -> false
48-
}
49-
)
42+
assertEquals(cause.domain, NSURLErrorDomain)
43+
assertEquals(cause.code, NSURLErrorCannotConnectToHost)
5044
}
5145

5246
@Test

0 commit comments

Comments
 (0)