Skip to content

Instantly share code, notes, and snippets.

@aqua30
Created August 23, 2022 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aqua30/a52110e252ee64814a3bbd231d8f8698 to your computer and use it in GitHub Desktop.
Save aqua30/a52110e252ee64814a3bbd231d8f8698 to your computer and use it in GitHub Desktop.
@Test
fun `for user id not available, api must return with http code 404 and null user object`() = runTest {
val expectedResponse = MockResponse()
.setResponseCode(HttpURLConnection.HTTP_NOT_FOUND)
mockWebServer.enqueue(expectedResponse)
val actualResponse = repository.getUserById(1)
assertThat(actualResponse.httpCode).isEqualTo(HttpURLConnection.HTTP_NOT_FOUND)
assertThat(actualResponse.body).isNull()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment