1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00

chore(cli): clarify use of concurrency option (#7840)

* add <number>

* add e2e tests

* add test with number
This commit is contained in:
Mert 2024-03-11 23:30:13 -04:00 committed by GitHub
parent e732cb68a7
commit d09980f646
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 1 deletions

View File

@ -44,7 +44,7 @@ program
.default(false), .default(false),
) )
.addOption( .addOption(
new Option('-c, --concurrency', 'Number of assets to upload at the same time') new Option('-c, --concurrency <number>', 'Number of assets to upload at the same time')
.env('IMMICH_UPLOAD_CONCURRENCY') .env('IMMICH_UPLOAD_CONCURRENCY')
.default(4), .default(4),
) )

View File

@ -142,4 +142,42 @@ describe(`immich upload`, () => {
expect(assets.length).toBe(9); expect(assets.length).toBe(9);
}); });
}); });
describe('immich upload --concurrency <number>', () => {
it('should work', async () => {
const { stderr, stdout, exitCode } = await immichCli([
'upload',
`${testAssetDir}/albums/nature/`,
'--concurrency',
'2',
]);
expect(stderr).toBe('');
expect(stdout.split('\n')).toEqual(
expect.arrayContaining([expect.stringContaining('Successfully uploaded 9 assets')]),
);
expect(exitCode).toBe(0);
const assets = await getAllAssets({}, { headers: asKeyAuth(key) });
expect(assets.length).toBe(9);
});
it('should reject string argument', async () => {
const { stderr, exitCode } = await immichCli([
'upload',
`${testAssetDir}/albums/nature/`,
'--concurrency string',
]);
expect(stderr).toContain('unknown option');
expect(exitCode).not.toBe(0);
});
it('should reject command without number', async () => {
const { stderr, exitCode } = await immichCli(['upload', `${testAssetDir}/albums/nature/`, '--concurrency']);
expect(stderr).toContain('argument missing');
expect(exitCode).not.toBe(0);
});
});
}); });