@@ -20,7 +20,6 @@ import kotlinx.coroutines.Deferred
2020import kotlinx.coroutines.Job
2121import kotlinx.coroutines.delay
2222import kotlinx.coroutines.flow.first
23- import kotlinx.coroutines.runBlocking
2423import kotlinx.coroutines.test.runTest
2524import kotlinx.coroutines.yield
2625import org.assertj.core.api.Assertions.assertThat
@@ -314,26 +313,26 @@ open class CodeWhispererTestBase {
314313 val psiFileCaptor = argumentCaptor<PsiFile >()
315314 val latencyContextCaptor = argumentCaptor<LatencyContext >()
316315
317- runBlocking {
318- whenever(codewhispererService.getRequestContext(
319- triggerTypeCaptor.capture(),
320- editorCaptor.capture(),
321- projectCaptor.capture(),
322- psiFileCaptor.capture(),
323- latencyContextCaptor.capture()
316+ doSuspendableAnswer {
317+ val requestContext = codewhispererService.getRequestContext(
318+ triggerTypeCaptor.firstValue,
319+ editorCaptor.firstValue,
320+ projectRule.project,
321+ psiFileCaptor.firstValue,
322+ latencyContextCaptor.firstValue
323+ )
324+ projectRule.fixture.type(userInput)
325+ requestContext
326+ }.doCallRealMethod()
327+ .wheneverBlocking(codewhispererService) {
328+ getRequestContext(
329+ triggerTypeCaptor.capture(),
330+ editorCaptor.capture(),
331+ projectCaptor.capture(),
332+ psiFileCaptor.capture(),
333+ latencyContextCaptor.capture()
324334 )
325- ).doSuspendableAnswer {
326- val requestContext = codewhispererService.getRequestContext(
327- triggerTypeCaptor.firstValue,
328- editorCaptor.firstValue,
329- projectRule.project,
330- psiFileCaptor.firstValue,
331- latencyContextCaptor.firstValue
332- )
333- projectRule.fixture.type(userInput)
334- requestContext
335- }.thenCallRealMethod()
336- }
335+ }
337336 }
338337
339338 fun mockLspInlineCompletionResponse (response : InlineCompletionListWithReferences ) {
0 commit comments