From d09980f6461067ff2fadc91467b8931aac801131 Mon Sep 17 00:00:00 2001 From: Mert <101130780+mertalev@users.noreply.github.com> Date: Mon, 11 Mar 2024 23:30:13 -0400 Subject: [PATCH] chore(cli): clarify use of concurrency option (#7840) * add * add e2e tests * add test with number --- cli/src/index.ts | 2 +- e2e/src/cli/specs/upload.e2e-spec.ts | 38 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/cli/src/index.ts b/cli/src/index.ts index 1aab0386a1..e9485190a7 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -44,7 +44,7 @@ program .default(false), ) .addOption( - new Option('-c, --concurrency', 'Number of assets to upload at the same time') + new Option('-c, --concurrency ', 'Number of assets to upload at the same time') .env('IMMICH_UPLOAD_CONCURRENCY') .default(4), ) diff --git a/e2e/src/cli/specs/upload.e2e-spec.ts b/e2e/src/cli/specs/upload.e2e-spec.ts index 27362ef237..bc4382f98e 100644 --- a/e2e/src/cli/specs/upload.e2e-spec.ts +++ b/e2e/src/cli/specs/upload.e2e-spec.ts @@ -142,4 +142,42 @@ describe(`immich upload`, () => { expect(assets.length).toBe(9); }); }); + + describe('immich upload --concurrency ', () => { + 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); + }); + }); });