You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @haroldadmin I use your library and unfortunately the 5.0.0 changes are not fully backwards compatible.
If you have tests that use the code on the NetworkResponse model then your tests will break (as mine did) and you'll have to replace code with an actual Response instance.
Example (for those who run into this):
Pre 5.0.0 code with mockito:
Success: whenever(apiService.signOut(any())).thenReturn(NetworkResponse.Success(code = 200, body = Unit))
Error: whenever(apiService.signOut(any())).thenReturn(NetworkResponse.ServerError(code = 500, body = ErrorResponse("boom")))
New 5.0.0 Implementation:
Success: whenever(apiService.signOut(any())).thenReturn(NetworkResponse.Success(response = Response.success(200), body = Unit))
Error:
val errorResponse =Response.error<String>(500, "{\"error\": \"boom\"}".toResponseBody("application/json".toMediaTypeOrNull()))
whenever(apiService.signOut(any())).thenReturn(NetworkResponse.ServerError(response = errorResponse, body =ErrorResponse("boom")))
Note: toResponseBody and toMediaTypeOrNull are extension methods built into okhttp.
It would be good to include a CHANGELOG.md file in the repo with these notes (or somewhere accessile and easily found - I loo for a CHANGELOG.md file personally)
The text was updated successfully, but these errors were encountered:
Hey @haroldadmin I use your library and unfortunately the 5.0.0 changes are not fully backwards compatible.
If you have tests that use the
code
on theNetworkResponse
model then your tests will break (as mine did) and you'll have to replacecode
with an actual Response instance.Example (for those who run into this):
Pre 5.0.0 code with mockito:
Success:
whenever(apiService.signOut(any())).thenReturn(NetworkResponse.Success(code = 200, body = Unit))
Error:
whenever(apiService.signOut(any())).thenReturn(NetworkResponse.ServerError(code = 500, body = ErrorResponse("boom")))
New 5.0.0 Implementation:
Success:
whenever(apiService.signOut(any())).thenReturn(NetworkResponse.Success(response = Response.success(200), body = Unit))
Error:
Note:
toResponseBody
andtoMediaTypeOrNull
are extension methods built into okhttp.It would be good to include a CHANGELOG.md file in the repo with these notes (or somewhere accessile and easily found - I loo for a CHANGELOG.md file personally)
The text was updated successfully, but these errors were encountered: