Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>', 'Number of assets to upload at the same time')
.env('IMMICH_UPLOAD_CONCURRENCY')
.default(4),
)
Expand Down
38 changes: 38 additions & 0 deletions e2e/src/cli/specs/upload.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,42 @@ describe(`immich upload`, () => {
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);
});
});
});