Skip to content

Commit 462414b

Browse files
committed
work on test file
1 parent b0943ff commit 462414b

File tree

1 file changed

+75
-6
lines changed

1 file changed

+75
-6
lines changed

packages/core/src/test/codewhisperer/zipcode.test.ts

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,84 @@
55
import assert from 'assert'
66
import * as sinon from 'sinon'
77
import { performanceTest } from '../../shared/performance/performance'
8+
import { fs, globals } from '../../shared'
9+
import * as CodeWhispererConstants from '../../codewhisperer/models/constants'
10+
import { TransformByQState, ZipManifest } from '../../codewhisperer'
11+
import { zipCode } from '../../codewhisperer/indexNode'
12+
import { createTestWorkspace } from '../testUtil'
13+
14+
interface SetupResult {
15+
tempDir: string
16+
tempFileName: string
17+
transformQManifest: ZipManifest
18+
writeSpy: sinon.SinonSpy
19+
}
820

921
describe('zipCode', function () {
1022
describe('performance tests', function () {
11-
performanceTest({}, 'many small files in zip', function () {
12-
return {
13-
setup: async () => {},
14-
execute: async () => {},
15-
verify: async () => {},
16-
}
23+
afterEach(function () {
24+
sinon.resetHistory()
25+
sinon.restore()
1726
})
27+
28+
performanceTest(
29+
{
30+
testRuns: 10,
31+
linux: {
32+
userCpuUsage: 90,
33+
systemCpuUsage: 35,
34+
heapTotal: 4,
35+
},
36+
darwin: {
37+
userCpuUsage: 90,
38+
systemCpuUsage: 35,
39+
heapTotal: 4,
40+
},
41+
win32: {
42+
userCpuUsage: 90,
43+
systemCpuUsage: 35,
44+
heapTotal: 4,
45+
},
46+
},
47+
'many small files in zip',
48+
function () {
49+
return {
50+
setup: async () => {
51+
const transformByQState: TransformByQState = new TransformByQState()
52+
const tempFileName = `testfile-${globals.clock.Date.now()}.zip`
53+
const tempDir = (
54+
await createTestWorkspace(250, {
55+
fileNamePrefix: 'file',
56+
fileContent: '0123456789',
57+
fileNameSuffix: '.md',
58+
})
59+
).uri.fsPath
60+
const transformQManifest = new ZipManifest()
61+
transformByQState.setProjectPath(tempDir)
62+
transformQManifest.customBuildCommand = CodeWhispererConstants.skipUnitTestsBuildCommand
63+
return { tempDir, tempFileName, transformQManifest, writeSpy }
64+
},
65+
execute: async ({ tempDir, tempFileName, transformQManifest, writeSpy }: SetupResult) => {
66+
await zipCode({
67+
dependenciesFolder: {
68+
path: tempDir,
69+
name: tempFileName,
70+
},
71+
humanInTheLoopFlag: false,
72+
modulePath: tempDir,
73+
zipManifest: transformQManifest,
74+
})
75+
},
76+
verify: async (setup: SetupResult) => {
77+
// writes a zip to disk.
78+
assert.ok(setup.writeSpy.called)
79+
assert.ok(
80+
setup.writeSpy.getCalls()[0].args[0].includes('.zip') ||
81+
setup.writeSpy.getCalls()[1].args[0].includes('.zip')
82+
)
83+
},
84+
}
85+
}
86+
)
1887
})
1988
})

0 commit comments

Comments
 (0)