-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional EmbraceUrlConnectionDelegate unit tests and bug fixes (#50)
## Goal Add additional unit tests for more cases for logging URLConnection requests and fix a few issues that were found. Specifically: - Making it more consistent and efficient when the SDK is not on to bypass the logging code - Add query string to the URL logged if there's a custom path override - Record response body even when the network call data had been previously cached. ## Testing Add unit tests of important cases where breakage may not be obvious
- Loading branch information
1 parent
eded592
commit 830b97e
Showing
6 changed files
with
986 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...t/java/io/embrace/android/embracesdk/internal/network/http/EmbraceHttpPathOverrideTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.embrace.android.embracesdk.internal.network.http | ||
|
||
import io.mockk.every | ||
import io.mockk.mockk | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
internal class EmbraceHttpPathOverrideTest { | ||
|
||
@Test | ||
fun `check override path validity`() { | ||
val request: HttpPathOverrideRequest = mockk(relaxed = true) | ||
every { request.urlString } answers { defaultUrl } | ||
every { request.getOverriddenURL(customPath) } answers { customUrl } | ||
every { request.getOverriddenURL("/error") } answers { throw RuntimeException() } | ||
|
||
assertEquals(defaultUrl, EmbraceHttpPathOverride.getURLString(request, null)) | ||
assertEquals(defaultUrl, EmbraceHttpPathOverride.getURLString(request, "")) | ||
assertEquals(defaultUrl, EmbraceHttpPathOverride.getURLString(request, "/a".repeat(1025))) | ||
assertEquals(defaultUrl, EmbraceHttpPathOverride.getURLString(request, "/屈福特")) | ||
assertEquals(defaultUrl, EmbraceHttpPathOverride.getURLString(request, "watford")) | ||
assertEquals(defaultUrl, EmbraceHttpPathOverride.getURLString(request, "/custom#")) | ||
assertEquals(defaultUrl, EmbraceHttpPathOverride.getURLString(request, "")) | ||
assertEquals(defaultUrl, EmbraceHttpPathOverride.getURLString(request, "/error")) | ||
assertEquals(customUrl, EmbraceHttpPathOverride.getURLString(request, customPath)) | ||
} | ||
|
||
companion object { | ||
private const val defaultUrl = "https://embrace.io/default-path" | ||
private const val customPath = "/custom-path" | ||
private const val customUrl = "https://embrace.io$customPath" | ||
} | ||
} |
Oops, something went wrong.