Skip to content

Commit 3b04d88

Browse files
committed
fix: failing tests after various changes
1 parent a446735 commit 3b04d88

File tree

5 files changed

+87
-26
lines changed

5 files changed

+87
-26
lines changed

src/base/deployBase.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const messages = Messages.loadMessages('@salesforce/plugin-data-code-extension',
99

1010
export type BaseDeployFlags = {
1111
name: string;
12-
'package-version': string;
12+
version: string;
1313
description: string;
1414
'package-dir': string;
1515
'target-org': Org;
@@ -36,7 +36,7 @@ export abstract class DeployBase<TFlags extends BaseDeployFlags = BaseDeployFlag
3636
description: messages.getMessage('flags.name.description'),
3737
required: true,
3838
}),
39-
'package-version': Flags.string({
39+
version: Flags.string({
4040
summary: messages.getMessage('flags.version.summary'),
4141
description: messages.getMessage('flags.version.description'),
4242
required: true,
@@ -79,7 +79,7 @@ export abstract class DeployBase<TFlags extends BaseDeployFlags = BaseDeployFlag
7979
const cmdMessages = this.getMessages();
8080

8181
const name = flags.name;
82-
const version = flags['package-version'];
82+
const version = flags.version;
8383
const description = flags.description;
8484
const packageDir = flags['package-dir'];
8585
const targetOrg = flags['target-org'];

test/commands/data-code-extension/deploy.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ describe('data-code-extension deploy', () => {
212212
'--target-org',
213213
'test@example.com',
214214
'--function-invoke-opt',
215-
'sync',
215+
'UnstructuredChunking',
216216
]);
217217

218218
expect(sfCommandStubs.log.calledWith('Data Code Extension deployment completed successfully!')).to.be.true;
@@ -233,10 +233,10 @@ describe('data-code-extension deploy', () => {
233233
'--target-org',
234234
'test@example.com',
235235
'--function-invoke-opt',
236-
'sync',
236+
'UnstructuredChunking',
237237
]);
238238

239-
expect(binaryDeployStub.firstCall.args[7]).to.equal('sync');
239+
expect(binaryDeployStub.firstCall.args[7]).to.equal('UnstructuredChunking');
240240
});
241241

242242
it('should validate CPU size options', async () => {
@@ -278,7 +278,7 @@ describe('data-code-extension deploy', () => {
278278
'--target-org',
279279
'test@example.com',
280280
'--function-invoke-opt',
281-
'sync',
281+
'UnstructuredChunking',
282282
]);
283283
expect.fail('Should have thrown an error');
284284
} catch (error) {
@@ -303,7 +303,7 @@ describe('data-code-extension deploy', () => {
303303
'--target-org',
304304
'test@example.com',
305305
'--function-invoke-opt',
306-
'sync',
306+
'UnstructuredChunking',
307307
]);
308308
expect.fail('Should have thrown an error');
309309
} catch (error) {
@@ -360,7 +360,6 @@ describe('data-code-extension deploy', () => {
360360
testDir,
361361
'--target-org',
362362
'test@example.com',
363-
'--json',
364363
]);
365364

366365
expect(result).to.have.property('success', true);

test/commands/data-code-extension/init.test.ts

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,17 @@ describe('data-code-extension init commands', () => {
6666
// If Python 3.11+ is not installed, pip package is missing, binary is not found, or init fails, verify the error is handled correctly
6767
expect(error).to.have.property('name');
6868
if (error instanceof Error) {
69-
expect(error.name).to.be.oneOf(['PythonNotFound', 'PythonVersionMismatch', 'PipNotFound', 'PackageNotInstalled', 'BinaryNotFound', 'BinaryNotExecutable', 'InitPermissionDenied', 'InitDirectoryExists', 'InitExecutionFailed']);
69+
expect(error.name).to.be.oneOf([
70+
'PythonNotFound',
71+
'PythonVersionMismatch',
72+
'PipNotFound',
73+
'PackageNotInstalled',
74+
'BinaryNotFound',
75+
'BinaryNotExecutable',
76+
'InitPermissionDenied',
77+
'InitDirectoryExists',
78+
'InitExecutionFailed',
79+
]);
7080
expect(error.message).to.be.a('string');
7181
if ('actions' in error && error.actions) {
7282
expect(error.actions).to.be.an('array');
@@ -75,9 +85,9 @@ describe('data-code-extension init commands', () => {
7585
}
7686
});
7787

78-
it('returns JSON result when --json flag is used for script init', async () => {
88+
it('returns structured result for script init', async () => {
7989
try {
80-
const result = await ScriptInit.run(['--json', '--package-dir', './test-json']);
90+
const result = await ScriptInit.run(['--package-dir', './test-json']);
8191

8292
// Should return a structured result
8393
expect(result).to.be.an('object');
@@ -86,7 +96,6 @@ describe('data-code-extension init commands', () => {
8696
expect(result).to.have.property('message');
8797
// packageInfo may or may not be present depending on whether package is installed
8898
} catch (error) {
89-
// Even errors should be structured when using --json
9099
expect(error).to.have.property('name');
91100
if (error instanceof Error) {
92101
expect(error.name).to.be.a('string');
@@ -104,7 +113,17 @@ describe('data-code-extension init commands', () => {
104113
} catch (error) {
105114
// Handle case where Python is not installed
106115
if (error instanceof Error) {
107-
expect(error.name).to.be.oneOf(['PythonNotFound', 'PythonVersionMismatch', 'PipNotFound', 'PackageNotInstalled', 'BinaryNotFound', 'BinaryNotExecutable', 'InitPermissionDenied', 'InitDirectoryExists', 'InitExecutionFailed']);
116+
expect(error.name).to.be.oneOf([
117+
'PythonNotFound',
118+
'PythonVersionMismatch',
119+
'PipNotFound',
120+
'PackageNotInstalled',
121+
'BinaryNotFound',
122+
'BinaryNotExecutable',
123+
'InitPermissionDenied',
124+
'InitDirectoryExists',
125+
'InitExecutionFailed',
126+
]);
108127
}
109128
}
110129
});
@@ -117,7 +136,17 @@ describe('data-code-extension init commands', () => {
117136
} catch (error) {
118137
// Handle case where Python is not installed
119138
if (error instanceof Error) {
120-
expect(error.name).to.be.oneOf(['PythonNotFound', 'PythonVersionMismatch', 'PipNotFound', 'PackageNotInstalled', 'BinaryNotFound', 'BinaryNotExecutable', 'InitPermissionDenied', 'InitDirectoryExists', 'InitExecutionFailed']);
139+
expect(error.name).to.be.oneOf([
140+
'PythonNotFound',
141+
'PythonVersionMismatch',
142+
'PipNotFound',
143+
'PackageNotInstalled',
144+
'BinaryNotFound',
145+
'BinaryNotExecutable',
146+
'InitPermissionDenied',
147+
'InitDirectoryExists',
148+
'InitExecutionFailed',
149+
]);
121150
}
122151
}
123152
});
@@ -130,7 +159,17 @@ describe('data-code-extension init commands', () => {
130159
} catch (error) {
131160
// Handle case where Python is not installed
132161
if (error instanceof Error) {
133-
expect(error.name).to.be.oneOf(['PythonNotFound', 'PythonVersionMismatch', 'PipNotFound', 'PackageNotInstalled', 'BinaryNotFound', 'BinaryNotExecutable', 'InitPermissionDenied', 'InitDirectoryExists', 'InitExecutionFailed']);
162+
expect(error.name).to.be.oneOf([
163+
'PythonNotFound',
164+
'PythonVersionMismatch',
165+
'PipNotFound',
166+
'PackageNotInstalled',
167+
'BinaryNotFound',
168+
'BinaryNotExecutable',
169+
'InitPermissionDenied',
170+
'InitDirectoryExists',
171+
'InitExecutionFailed',
172+
]);
134173
}
135174
}
136175
});

test/commands/data-code-extension/scan.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ describe('data-code-extension scan commands', () => {
360360
filesScanned: ['main.py'],
361361
});
362362

363-
const result = await ScriptScan.run(['--json']);
363+
const result = await ScriptScan.run([]);
364364

365365
expect(result).to.be.an('object');
366366
expect(result.success).to.be.true;

test/commands/data-code-extension/zip.test.ts

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,20 @@ describe('data-code-extension zip commands', () => {
7171
expect(error).to.have.property('name');
7272
if (error instanceof Error) {
7373
// Check for various error types including generic Error from missing directory
74-
expect(error.name).to.be.oneOf(['Error', 'PythonNotFound', 'PythonVersionMismatch', 'PipNotFound', 'PackageNotInstalled', 'BinaryNotFound', 'BinaryNotExecutable', 'ZipPermissionDenied', 'PackageDirNotFound', 'NotInitializedPackage', 'InsufficientDiskSpace', 'ZipExecutionFailed']);
74+
expect(error.name).to.be.oneOf([
75+
'Error',
76+
'PythonNotFound',
77+
'PythonVersionMismatch',
78+
'PipNotFound',
79+
'PackageNotInstalled',
80+
'BinaryNotFound',
81+
'BinaryNotExecutable',
82+
'ZipPermissionDenied',
83+
'PackageDirNotFound',
84+
'NotInitializedPackage',
85+
'InsufficientDiskSpace',
86+
'ZipExecutionFailed',
87+
]);
7588
expect(error.message).to.be.a('string');
7689
if ('actions' in error && error.actions) {
7790
expect(error.actions).to.be.an('array');
@@ -94,9 +107,9 @@ describe('data-code-extension zip commands', () => {
94107
}
95108
});
96109

97-
it('returns JSON result when --json flag is used for script zip', async () => {
110+
it('returns structured result for script zip', async () => {
98111
try {
99-
const result = await ScriptZip.run(['--json', '--package-dir', './test-json']);
112+
const result = await ScriptZip.run(['--package-dir', './test-json']);
100113

101114
// Should return a structured result
102115
expect(result).to.be.an('object');
@@ -106,7 +119,6 @@ describe('data-code-extension zip commands', () => {
106119
expect(result).to.have.property('packageDir');
107120
// archivePath may or may not be present depending on whether zip succeeded
108121
} catch (error) {
109-
// Even errors should be structured when using --json
110122
expect(error).to.have.property('name');
111123
if (error instanceof Error) {
112124
expect(error.name).to.be.a('string');
@@ -153,7 +165,19 @@ describe('data-code-extension zip commands', () => {
153165
// Handle errors gracefully
154166
expect(error).to.have.property('name');
155167
if (error instanceof Error) {
156-
expect(error.name).to.be.oneOf(['PythonNotFound', 'PythonVersionMismatch', 'PipNotFound', 'PackageNotInstalled', 'BinaryNotFound', 'BinaryNotExecutable', 'ZipPermissionDenied', 'PackageDirNotFound', 'NotInitializedPackage', 'InsufficientDiskSpace', 'ZipExecutionFailed']);
168+
expect(error.name).to.be.oneOf([
169+
'PythonNotFound',
170+
'PythonVersionMismatch',
171+
'PipNotFound',
172+
'PackageNotInstalled',
173+
'BinaryNotFound',
174+
'BinaryNotExecutable',
175+
'ZipPermissionDenied',
176+
'PackageDirNotFound',
177+
'NotInitializedPackage',
178+
'InsufficientDiskSpace',
179+
'ZipExecutionFailed',
180+
]);
157181
expect(error.message).to.be.a('string');
158182
}
159183
}
@@ -173,9 +197,9 @@ describe('data-code-extension zip commands', () => {
173197
}
174198
});
175199

176-
it('returns JSON result when --json flag is used for function zip', async () => {
200+
it('returns structured result for function zip', async () => {
177201
try {
178-
const result = await FunctionZip.run(['--json', '--package-dir', './test-function-json']);
202+
const result = await FunctionZip.run(['--package-dir', './test-function-json']);
179203

180204
// Should return a structured result
181205
expect(result).to.be.an('object');
@@ -184,12 +208,11 @@ describe('data-code-extension zip commands', () => {
184208
expect(result).to.have.property('message');
185209
expect(result).to.have.property('packageDir');
186210
} catch (error) {
187-
// Even errors should be structured when using --json
188211
expect(error).to.have.property('name');
189212
if (error instanceof Error) {
190213
expect(error.name).to.be.a('string');
191214
expect(error.message).to.be.a('string');
192215
}
193216
}
194217
});
195-
});
218+
});

0 commit comments

Comments
 (0)