Skip to content

Commit e07b89c

Browse files
Copiloteleanorjboyd
andcommitted
Add comprehensive tests for pythonProjects settings validation
Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
1 parent 3a2cb48 commit e07b89c

2 files changed

Lines changed: 464 additions & 5 deletions

File tree

src/features/settings/settingsValidation.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ interface InvalidProjectEntry {
2222
* @returns An error message if invalid, undefined if valid
2323
*/
2424
function validateProjectEntry(entry: PythonProjectSettings): string | undefined {
25+
// Check if entry is a valid object (not a string, array, null, or other primitive)
26+
if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) {
27+
return l10n.t('Invalid entry format: expected object');
28+
}
29+
2530
// Check if required fields exist
2631
if (!entry.path) {
2732
return l10n.t('Missing required field: path');
@@ -35,11 +40,6 @@ function validateProjectEntry(entry: PythonProjectSettings): string | undefined
3540
return l10n.t('Missing required field: packageManager');
3641
}
3742

38-
// Check if entry is a valid object (not a string or other primitive)
39-
if (typeof entry !== 'object') {
40-
return l10n.t('Invalid entry format: expected object');
41-
}
42-
4343
return undefined;
4444
}
4545

0 commit comments

Comments
 (0)