Skip to content

Instantly share code, notes, and snippets.

@aqua30
Created August 23, 2022 15:18
Show Gist options
  • Save aqua30/e10a8aab699a49fe1e378bbc7c6c70c8 to your computer and use it in GitHub Desktop.
Save aqua30/e10a8aab699a49fe1e378bbc7c6c70c8 to your computer and use it in GitHub Desktop.
@Test
fun `for multiple users, api must return all users with http code 200`() = runTest {
val users = listOf(
User(1,"Saurabh","Delhi","India"),
User(2,"Zergain","London","UK"),
)
val expectedResponse = MockResponse()
.setResponseCode(HttpURLConnection.HTTP_OK)
.setBody(Gson().toJson(users))
mockWebServer.enqueue(expectedResponse)
val actualResponse = repository.getAllUsers()
assertThat(actualResponse.body).hasSize(2)
assertThat(actualResponse.body).isEqualTo(users)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment