Skip to content

Commit 1a2017b

Browse files
committed
add spy for vfs
1 parent 3a11a85 commit 1a2017b

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

packages/core/src/testInteg/perf/registerNewFiles.test.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55
import assert from 'assert'
6+
import sinon from 'sinon'
67
import * as vscode from 'vscode'
78
import { NewFileInfo, NewFileZipContents, registerNewFiles } from '../../amazonqFeatureDev'
89
import { performanceTest } from '../../shared/performance/performance'
@@ -12,6 +13,8 @@ import { VirtualFileSystem } from '../../shared'
1213
interface SetupResult {
1314
workspace: vscode.WorkspaceFolder
1415
fileContents: NewFileZipContents[]
16+
vfsSpy: sinon.SinonSpiedInstance<VirtualFileSystem>
17+
vfs: VirtualFileSystem
1518
}
1619

1720
function getFileContents(numFiles: number, fileSize: number): NewFileZipContents[] {
@@ -31,17 +34,17 @@ function performanceTestWrapper(label: string, numFiles: number, fileSize: numbe
3134
linux: {
3235
userCpuUsage: 200,
3336
systemCpuUsage: 35,
34-
heapTotal: 8,
37+
heapTotal: 16,
3538
},
3639
darwin: {
3740
userCpuUsage: 200,
3841
systemCpuUsage: 35,
39-
heapTotal: 8,
42+
heapTotal: 16,
4043
},
4144
win32: {
4245
userCpuUsage: 200,
4346
systemCpuUsage: 35,
44-
heapTotal: 8,
47+
heapTotal: 16,
4548
},
4649
},
4750
label,
@@ -50,26 +53,35 @@ function performanceTestWrapper(label: string, numFiles: number, fileSize: numbe
5053
setup: async () => {
5154
const testWorkspaceUri = vscode.Uri.file(getTestWorkspaceFolder())
5255
const fileContents = getFileContents(numFiles, fileSize)
56+
const vfs = new VirtualFileSystem()
57+
const vfsSpy = sinon.spy(vfs)
58+
5359
return {
5460
workspace: {
5561
uri: testWorkspaceUri,
5662
name: 'test-workspace',
5763
index: 0,
5864
},
5965
fileContents: fileContents,
66+
vfsSpy: vfsSpy,
67+
vfs: vfs,
6068
}
6169
},
6270
execute: async (setup: SetupResult) => {
6371
return registerNewFiles(
64-
new VirtualFileSystem(),
72+
setup.vfs,
6573
setup.fileContents,
6674
'test-upload-id',
6775
[setup.workspace],
6876
conversationId
6977
)
7078
},
71-
verify: async (_setup: SetupResult, result: NewFileInfo[]) => {
79+
verify: async (setup: SetupResult, result: NewFileInfo[]) => {
7280
assert.strictEqual(result.length, numFiles)
81+
assert.ok(
82+
setup.vfsSpy.registerProvider.callCount <= numFiles,
83+
'only register each file once in vfs'
84+
)
7385
},
7486
}
7587
}

0 commit comments

Comments
 (0)