Skip to content

Commit bc9bd8b

Browse files
committed
test: add more tests for behavior
1 parent 752500e commit bc9bd8b

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { fs } from '../../shared/fs/fs'
1717
import { CodeWhispererConstants } from '../../codewhisperer/indexNode'
1818
import { CurrentWsFolders, defaultExcludePatterns } from '../../shared/utilities/workspaceUtils'
1919
import { TestFolder } from '../testUtil'
20-
import { NoActiveFileError } from '../../codewhisperer/models/errors'
20+
import { NoActiveFileError, NoSourceFilesError } from '../../codewhisperer/models/errors'
2121

2222
describe('zipUtil', function () {
2323
const workspaceFolder = getTestWorkspaceFolder()
@@ -231,4 +231,36 @@ describe('zipUtil', function () {
231231

232232
assert.strictEqual(zipMetadata.language, 'typescript')
233233
})
234+
235+
it('able to process files outside of workspace', async function () {
236+
const project = await TestFolder.create()
237+
const fileName = 'thisIsPartOfMyProject.py'
238+
await project.write(fileName, 'file1')
239+
const filepath = path.join(project.path, fileName)
240+
await vscode.window.showTextDocument(vscode.Uri.parse(filepath))
241+
const zipMetadata = await zipUtil.zipProject(
242+
[...(vscode.workspace.workspaceFolders ?? [])] as CurrentWsFolders,
243+
defaultExcludePatterns,
244+
{
245+
includeNonWorkspaceFiles: true,
246+
}
247+
)
248+
249+
assert.strictEqual(zipMetadata.scannedFiles.has(path.join(project.path, fileName)), true)
250+
})
251+
252+
it('throws on empty project', async function () {
253+
const project = await TestFolder.create()
254+
await assert.rejects(
255+
async () =>
256+
await zipUtil.zipProject(
257+
[{ uri: vscode.Uri.file(project.path), name: 'project1', index: 0 }] as CurrentWsFolders,
258+
defaultExcludePatterns,
259+
{
260+
includeNonWorkspaceFiles: true,
261+
}
262+
),
263+
new NoSourceFilesError()
264+
)
265+
})
234266
})

0 commit comments

Comments
 (0)