Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove flaky test case #1381

Merged
merged 1 commit into from
Sep 23, 2021
Merged
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 @@ -22,7 +22,6 @@ import org.mockito.Mockito
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.junit.MockitoJUnitRunner
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit

@RunWith(MockitoJUnitRunner::class)
Expand Down Expand Up @@ -96,49 +95,6 @@ class ComplexRequestIntegrationTest {
}
}

/**
* Performs a GET request but manually cancel it before it can complete
*/
@Test
fun cancelledRequest() {
val server = MockWebServer().apply { start() }
val url = server.url("/test")
val request = Request.Builder().url(url).build()
val plugin = BugsnagOkHttpPlugin().apply { load(client) }

// make a request but then cancel it on another thread before completion
val okHttpClient = OkHttpClient.Builder().eventListener(plugin).build()
val call = okHttpClient.newCall(request)

Executors.newSingleThreadScheduledExecutor().schedule(
{
call.cancel()
},
100, TimeUnit.MILLISECONDS
)

runCatching {
call.execute().close()
}
server.shutdown()

// verify breadcrumb received
verify(client, times(1)).leaveBreadcrumb(
eq("OkHttp call error"),
mapCaptor.capture(),
eq(BreadcrumbType.REQUEST)
)
with(mapCaptor.value) {
assertEquals("GET", get("method"))
assertEquals(0L, get("requestContentLength"))
assertTrue(get("duration") is Long)
assertNull(get("urlParams"))
assertEquals(url.toString(), get("url"))
assertNull(get("status"))
assertNull(get("responseContentLength"))
}
}

/**
* Performs a GET request that does not close an empty response body. This is captured
* as a breadcrumb regardless.
Expand Down