Skip to content

Commit

Permalink
Add a test for content-type (#6328)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin authored Dec 17, 2024
1 parent 1c9d334 commit bf2f7b8
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.apollographql.apollo.interceptor.ApolloInterceptorChain
import com.apollographql.apollo.network.http.HttpInfo
import com.apollographql.apollo.testing.internal.runTest
import com.apollographql.mockserver.MockServer
import com.apollographql.mockserver.enqueueError
import com.apollographql.mockserver.enqueueString
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.onEach
Expand All @@ -34,6 +35,21 @@ class HttpNetworkTransportTest {
}
}

@Test
fun postContentTypeIsApplicationJson() = runTest {
MockServer().use { mockServer ->
ApolloClient.Builder()
.serverUrl(mockServer.url())
.build()
.use { apolloClient ->
mockServer.enqueueError(500)
apolloClient.query(FooQuery()).execute()
val headers = mockServer.takeRequest().headers
assertEquals("application/json", headers.get("Content-Type"))
}
}
}

@Test
fun interceptorCanRestoreThrowingBehaviour() = runTest {
MockServer().use { mockServer ->
Expand Down

0 comments on commit bf2f7b8

Please sign in to comment.