@@ -10,13 +10,25 @@ import {
1010 ContentLengthError ,
1111 maxRepoSizeBytes ,
1212} from 'aws-core-vscode/amazonqFeatureDev'
13- import { assertTelemetry , createTestWorkspace } from 'aws-core-vscode/test'
13+ import { assertTelemetry , createTestWorkspace , getWorkspaceFolder , TestFolder } from 'aws-core-vscode/test'
1414import { fs , AmazonqCreateUpload } from 'aws-core-vscode/shared'
1515import { Span } from 'aws-core-vscode/telemetry'
1616import sinon from 'sinon'
17+ import { CodeWhispererSettings } from 'aws-core-vscode/codewhisperer'
18+
19+ const getWorkspaceWithDevFile = async ( ) => {
20+ const folder = await TestFolder . create ( )
21+ await folder . write ( 'devfile.yaml' , 'test' )
22+ await folder . write ( 'file.md' , 'test content' )
23+ return getWorkspaceFolder ( folder . path )
24+ }
1725
1826describe ( 'file utils' , ( ) => {
1927 describe ( 'prepareRepoData' , function ( ) {
28+ afterEach ( ( ) => {
29+ sinon . restore ( )
30+ } )
31+
2032 it ( 'returns files in the workspace as a zip' , async function ( ) {
2133 // these variables are a manual selection of settings for the test in order to test the collectFiles function
2234 const fileAmount = 2
@@ -56,6 +68,37 @@ describe('file utils', () => {
5668 assertTelemetry ( 'amazonq_bundleExtensionIgnored' , { filenameExt : 'mp4' , count : 1 } )
5769 } )
5870
71+ it ( 'should ignore devfile.yaml when setting is disabled' , async function ( ) {
72+ const workspace = await getWorkspaceWithDevFile ( )
73+ sinon . stub ( CodeWhispererSettings . instance , 'getDevCommandWorkspaceConfigurations' ) . returns ( { } )
74+
75+ const telemetry = new TelemetryHelper ( )
76+ const result = await prepareRepoData ( [ workspace . uri . fsPath ] , [ workspace ] , telemetry , {
77+ record : ( ) => { } ,
78+ } as unknown as Span < AmazonqCreateUpload > )
79+ assert . strictEqual ( Buffer . isBuffer ( result . zipFileBuffer ) , true )
80+ // checksum is not the same across different test executions because some unique random folder names are generated
81+ assert . strictEqual ( result . zipFileChecksum . length , 44 )
82+ assert . strictEqual ( telemetry . repositorySize , 12 )
83+ sinon . reset ( )
84+ } )
85+
86+ it ( 'should include devfile.yaml when setting is enabled' , async function ( ) {
87+ const workspace = await getWorkspaceWithDevFile ( )
88+ sinon . stub ( CodeWhispererSettings . instance , 'getDevCommandWorkspaceConfigurations' ) . returns ( {
89+ [ workspace . uri . fsPath ] : true ,
90+ } )
91+
92+ const telemetry = new TelemetryHelper ( )
93+ const result = await prepareRepoData ( [ workspace . uri . fsPath ] , [ workspace ] , telemetry , {
94+ record : ( ) => { } ,
95+ } as unknown as Span < AmazonqCreateUpload > )
96+ assert . strictEqual ( Buffer . isBuffer ( result . zipFileBuffer ) , true )
97+ // checksum is not the same across different test executions because some unique random folder names are generated
98+ assert . strictEqual ( result . zipFileChecksum . length , 44 )
99+ assert . strictEqual ( telemetry . repositorySize , 16 )
100+ } )
101+
59102 // Test the logic that allows the customer to modify root source folder
60103 it ( 'prepareRepoData throws a ContentLengthError code when repo is too big' , async function ( ) {
61104 const workspace = await createTestWorkspace ( 1 , { } )
0 commit comments