Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ internal class IdentifiersEncoder(

return "e:$id"
} catch (e: Exception) {
Log.e("OptableSDK", "Can't get eid from $urlString", e)
Log.e("OptableSDK", "Can't get eid from deep link", e)
}
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ internal class NetworkClient(
if (response.isSuccessful) {
return@withContext NetworkResponse.Success(response.body()!!)
} else {
return@withContext NetworkResponse.Error("Request failed with status code $response: ${response.errorBody()}")
return@withContext NetworkResponse.Error("Request failed with status code ${response.code()}: ${response.errorBody()?.string()}")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import io.mockk.mockk
import kotlinx.coroutines.runBlocking
import okhttp3.ResponseBody
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
Expand Down Expand Up @@ -59,14 +60,19 @@ class NetworkClientTest {

@Test
fun identify_shouldReturnError_whenApiCallIsUnsuccessful() = runBlocking {
val errorBody = ResponseBody.create(null, "Error")
val errorBody = ResponseBody.create(null, """{"error":"Tenant not found"}""")
val expectedResponse: Response<Unit> = Response.error(404, errorBody)

`when`(mockEdgeService.identify(emptyList())).thenReturn(expectedResponse)

val result = networkClient.identify(emptyList())

assertTrue(result is NetworkResponse.Error)
val message = (result as NetworkResponse.Error).message
assertTrue(message.contains("404"))
assertTrue(message.contains("Tenant not found"))
assertFalse(message.contains("url="))
assertFalse(message.contains("localhost"))
}

@Test
Expand Down
Loading