|
| 1 | +import assert from 'assert'; |
| 2 | +import { processEditableInstallArgs } from '../../../managers/builtin/utils'; |
| 3 | + |
| 4 | +suite('Process Editable Install Arguments Tests', () => { |
| 5 | + test('should handle empty args array', () => { |
| 6 | + const result = processEditableInstallArgs([]); |
| 7 | + assert.deepStrictEqual(result, [], 'Should return empty array for empty input'); |
| 8 | + }); |
| 9 | + |
| 10 | + test('should pass through non-editable install args unchanged', () => { |
| 11 | + const args = ['numpy', 'pandas==2.0.0', '--user']; |
| 12 | + const result = processEditableInstallArgs(args); |
| 13 | + assert.deepStrictEqual(result, args, 'Should return regular args unchanged'); |
| 14 | + }); |
| 15 | + |
| 16 | + test('should pass through single -e argument unchanged', () => { |
| 17 | + const args = ['-e', 'c:/path/to/package']; |
| 18 | + const result = processEditableInstallArgs(args); |
| 19 | + assert.deepStrictEqual(result, args, 'Should return single -e arg unchanged'); |
| 20 | + }); |
| 21 | + |
| 22 | + test('should pass through multiple unrelated -e arguments unchanged', () => { |
| 23 | + const args = ['-e', 'c:/path/to/package1', '-e', 'c:/path/to/package2']; |
| 24 | + const result = processEditableInstallArgs(args); |
| 25 | + assert.deepStrictEqual(result, args, 'Should return multiple unrelated -e args unchanged'); |
| 26 | + }); |
| 27 | + |
| 28 | + test('should combine -e with extras correctly', () => { |
| 29 | + const args = ['-e', 'c:/path/to/package', '-e', '.[testing]']; |
| 30 | + const expected = ['-e', 'c:/path/to/package[testing]']; |
| 31 | + const result = processEditableInstallArgs(args); |
| 32 | + assert.deepStrictEqual(result, expected, 'Should combine -e with extras correctly'); |
| 33 | + }); |
| 34 | + |
| 35 | + test('should handle multiple editable installs with extras correctly', () => { |
| 36 | + const args = ['-e', 'c:/path/to/package1', '-e', '.[testing]', '-e', 'c:/path/to/package2', '-e', '.[dev]']; |
| 37 | + const expected = ['-e', 'c:/path/to/package1[testing]', '-e', 'c:/path/to/package2[dev]']; |
| 38 | + const result = processEditableInstallArgs(args); |
| 39 | + assert.deepStrictEqual(result, expected, 'Should handle multiple editable installs with extras'); |
| 40 | + }); |
| 41 | + |
| 42 | + test('should handle mixed regular and editable installs correctly', () => { |
| 43 | + const args = ['numpy', '-e', 'c:/path/to/package', '-e', '.[testing]', 'pandas==2.0.0']; |
| 44 | + const expected = ['numpy', '-e', 'c:/path/to/package[testing]', 'pandas==2.0.0']; |
| 45 | + const result = processEditableInstallArgs(args); |
| 46 | + assert.deepStrictEqual(result, expected, 'Should handle mixed regular and editable installs'); |
| 47 | + }); |
| 48 | + |
| 49 | + test('should handle incomplete -e arguments gracefully', () => { |
| 50 | + const args = ['-e']; |
| 51 | + const result = processEditableInstallArgs(args); |
| 52 | + assert.deepStrictEqual(result, ['-e'], 'Should handle incomplete -e arguments'); |
| 53 | + }); |
| 54 | + |
| 55 | + test('should not combine -e args when second is not an extras specification', () => { |
| 56 | + const args = ['-e', 'c:/path/to/package1', '-e', 'c:/path/to/package2']; |
| 57 | + const result = processEditableInstallArgs(args); |
| 58 | + assert.deepStrictEqual(result, args, 'Should not combine when second -e arg is not an extras spec'); |
| 59 | + }); |
| 60 | + |
| 61 | + test('should handle extras with multiple requirements', () => { |
| 62 | + const args = ['-e', 'c:/path/to/package', '-e', '.[testing,dev]']; |
| 63 | + const expected = ['-e', 'c:/path/to/package[testing,dev]']; |
| 64 | + const result = processEditableInstallArgs(args); |
| 65 | + assert.deepStrictEqual(result, expected, 'Should handle extras with multiple requirements'); |
| 66 | + }); |
| 67 | + |
| 68 | + test('should handle Windows-style paths correctly', () => { |
| 69 | + const args = ['-e', 'C:\\path\\to\\package', '-e', '.[testing]']; |
| 70 | + const expected = ['-e', 'C:\\path\\to\\package[testing]']; |
| 71 | + const result = processEditableInstallArgs(args); |
| 72 | + assert.deepStrictEqual(result, expected, 'Should handle Windows paths correctly'); |
| 73 | + }); |
| 74 | + |
| 75 | + test('should handle editable installs followed by other args', () => { |
| 76 | + const args = ['-e', 'c:/path/to/package', '-e', '.[testing]', '--no-deps']; |
| 77 | + const expected = ['-e', 'c:/path/to/package[testing]', '--no-deps']; |
| 78 | + const result = processEditableInstallArgs(args); |
| 79 | + assert.deepStrictEqual(result, expected, 'Should handle editable installs followed by other args'); |
| 80 | + }); |
| 81 | +}); |
0 commit comments