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

Make sure to take into account setting to false arguments that are true by default #1353

Merged
merged 1 commit into from
Oct 26, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/arg-parser/src/arg-mapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ describe('arg-mapper.mapCliToDriver', () => {
});
});

context('when cli args have retryWrites set to false', () => {
const cliOptions: CliOptions = { retryWrites: false };

it('maps the same argument', () => {
expect(optionsTest(cliOptions)).to.deep.equal({
cs: 'mongodb://localhost/?retryWrites=false'
});
});
});

context('when cli args have tls', () => {
const cliOptions: CliOptions = { tls: true };

Expand Down
2 changes: 1 addition & 1 deletion packages/arg-parser/src/arg-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function mapOption<Key extends keyof CliOptions>(
export function mapCliToDriver(options: Readonly<CliOptions>, i: Readonly<ConnectionInfo>): ConnectionInfo {
for (const cliOption of Object.keys(options) as (keyof CliOptions)[]) {
const optionValue = options[cliOption];
if (optionValue) {
if (optionValue !== null && optionValue !== undefined && optionValue !== '') {
i = mapOption(i, cliOption, optionValue);
}
}
Expand Down