Skip to content

Commit 1cde7de

Browse files
committed
fix tst
1 parent 05eb0a7 commit 1cde7de

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererFileContextProviderTest.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class CodeWhispererFileContextProviderTest {
137137

138138
@Test
139139
fun `extractSupplementalFileContext should timeout 50ms`() = runTest {
140-
featureConfigService.stub { on { getInlineCompletion() } doReturn false }
140+
mockProjectContext.stub { onBlocking { queryInline(any(), any()) }.doReturn(emptyList()) }
141141
sut = spy(sut)
142142

143143
val files = NaiveSampleCase.setupFixture(fixture)
@@ -159,7 +159,8 @@ class CodeWhispererFileContextProviderTest {
159159
}
160160

161161
@Test
162-
fun `should only call and use openTabsContext if projectContext is disabled`() = runTest {
162+
fun `should only use openTabsContext if projectContext is empty`() = runTest {
163+
mockProjectContext.stub { onBlocking { queryInline(any(), any()) }.doReturn(emptyList()) }
163164
featureConfigService.stub { on { getInlineCompletion() } doReturn false }
164165
sut = spy(sut)
165166

@@ -169,7 +170,7 @@ class CodeWhispererFileContextProviderTest {
169170

170171
val result = sut.extractSupplementalFileContextForSrc(queryPsi, mockFileContext)
171172

172-
verify(sut, times(0)).fetchProjectContext(any(), any(), any())
173+
verify(sut, times(1)).fetchProjectContext(any(), any(), any())
173174
verify(sut, times(1)).fetchOpenTabsContext(any(), any(), any())
174175

175176
assertThat(result.isUtg).isFalse
@@ -217,19 +218,16 @@ class CodeWhispererFileContextProviderTest {
217218
}
218219

219220
@Test
220-
fun `should use project context if it is present`() = runTest {
221+
fun `should use both project context and open tabs if both are present`() = runTest {
221222
mockProjectContext.stub {
222223
runBlocking {
223224
doReturn(
224225
listOf(
225226
InlineBm25Chunk("project_context1", "path1", 0.0),
226-
InlineBm25Chunk("project_context2", "path2", 0.0),
227-
InlineBm25Chunk("project_context3", "path3", 0.0),
228227
)
229228
).whenever(it).queryInline(any(), any())
230229
}
231230
}
232-
featureConfigService.stub { on { getInlineCompletion() } doReturn true }
233231
sut = spy(sut)
234232
val files = NaiveSampleCase.setupFixture(fixture)
235233
val queryPsi = files[0]
@@ -238,8 +236,8 @@ class CodeWhispererFileContextProviderTest {
238236
val result = sut.extractSupplementalFileContextForSrc(queryPsi, mockFileContext)
239237

240238
assertThat(result.isUtg).isFalse
241-
assertThat(result.strategy).isEqualTo(CrossFileStrategy.ProjectContext)
242-
assertThat(result.contents).hasSize(3)
239+
assertThat(result.strategy).isEqualTo(CrossFileStrategy.Codemap)
240+
assertThat(result.contents).hasSize(4)
243241
}
244242

245243
@Test
@@ -420,6 +418,7 @@ class CodeWhispererFileContextProviderTest {
420418

421419
@Test
422420
fun `extractSupplementalFileContext from src file should extract src`() = runTest {
421+
mockProjectContext.stub { onBlocking { queryInline(any(), any()) }.doReturn(emptyList()) }
423422
val files = NaiveSampleCase.setupFixture(fixture)
424423
val queryPsi = files[0]
425424

0 commit comments

Comments
 (0)