Skip to content

fix: merge deploy api options #272

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

Merged
merged 1 commit into from
Mar 23, 2021
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
3 changes: 2 additions & 1 deletion src/client/metadataApiDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ export class MetadataApiDeploy extends MetadataTransfer<MetadataApiDeployStatus,

constructor(options: MetadataApiDeployOptions) {
super(options);
this.options = Object.assign({}, MetadataApiDeploy.DEFAULT_OPTIONS, options);
options.apiOptions = { ...MetadataApiDeploy.DEFAULT_OPTIONS.apiOptions, ...options.apiOptions };
this.options = Object.assign({}, options);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple ways to do this, and maybe it becomes MetadataApiDeploy.DEFAULT_API_OPTIONS but that was a more disruptive change so thought I'd start with this.

}

protected async pre(): Promise<{ id: string }> {
Expand Down
35 changes: 34 additions & 1 deletion test/client/metadataApiDeploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { expect } from 'chai';
import { basename, join } from 'path';
import { MOCK_ASYNC_RESULT, stubMetadataDeploy } from '../mock/client/transferOperations';
import { DeployResult } from '../../src/client/metadataApiDeploy';
import { DeployResult, MetadataApiDeploy } from '../../src/client/metadataApiDeploy';
import { mockRegistry, matchingContentFile } from '../mock/registry';
import { META_XML_SUFFIX } from '../../src/common';
import {
Expand Down Expand Up @@ -553,4 +553,37 @@ describe('MetadataApiDeploy', () => {
});
});
});

describe('Constructor', () => {
it('should merge default API options', () => {
const mdApiDeploy = new MetadataApiDeploy({
usernameOrConnection: 'testing',
components: new ComponentSet(),
apiOptions: {
checkOnly: true,
testLevel: 'RunLocalTests',
},
});
// @ts-ignore testing private property
const mdOpts = mdApiDeploy.options;
expect(mdOpts.apiOptions).to.have.property('checkOnly', true);
expect(mdOpts.apiOptions).to.have.property('rollbackOnError', true);
expect(mdOpts.apiOptions).to.have.property('ignoreWarnings', false);
expect(mdOpts.apiOptions).to.have.property('singlePackage', true);
expect(mdOpts.apiOptions).to.have.property('testLevel', 'RunLocalTests');
});

it('should use default API options', () => {
const mdApiDeploy = new MetadataApiDeploy({
usernameOrConnection: 'testing',
components: new ComponentSet(),
});
// @ts-ignore testing private property
const mdOpts = mdApiDeploy.options;
expect(mdOpts.apiOptions).to.have.property('rollbackOnError', true);
expect(mdOpts.apiOptions).to.have.property('ignoreWarnings', false);
expect(mdOpts.apiOptions).to.have.property('checkOnly', false);
expect(mdOpts.apiOptions).to.have.property('singlePackage', true);
});
});
});