Skip to content

Commit 64f86bd

Browse files
shetzelsfsholden
authored andcommitted
fix: merge deploy api options (#272)
this will merge deploy api options with the defaults rather than using them only when undefined
1 parent 1ac6792 commit 64f86bd

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/client/metadataApiDeploy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ export class MetadataApiDeploy extends MetadataTransfer<MetadataApiDeployStatus,
189189

190190
constructor(options: MetadataApiDeployOptions) {
191191
super(options);
192-
this.options = Object.assign({}, MetadataApiDeploy.DEFAULT_OPTIONS, options);
192+
options.apiOptions = { ...MetadataApiDeploy.DEFAULT_OPTIONS.apiOptions, ...options.apiOptions };
193+
this.options = Object.assign({}, options);
193194
}
194195

195196
protected async pre(): Promise<{ id: string }> {

test/client/metadataApiDeploy.test.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
import { expect } from 'chai';
1717
import { basename, join } from 'path';
1818
import { MOCK_ASYNC_RESULT, stubMetadataDeploy } from '../mock/client/transferOperations';
19-
import { DeployResult } from '../../src/client/metadataApiDeploy';
19+
import { DeployResult, MetadataApiDeploy } from '../../src/client/metadataApiDeploy';
2020
import { mockRegistry, matchingContentFile } from '../mock/registry';
2121
import { META_XML_SUFFIX } from '../../src/common';
2222
import {
@@ -553,4 +553,37 @@ describe('MetadataApiDeploy', () => {
553553
});
554554
});
555555
});
556+
557+
describe('Constructor', () => {
558+
it('should merge default API options', () => {
559+
const mdApiDeploy = new MetadataApiDeploy({
560+
usernameOrConnection: 'testing',
561+
components: new ComponentSet(),
562+
apiOptions: {
563+
checkOnly: true,
564+
testLevel: 'RunLocalTests',
565+
},
566+
});
567+
// @ts-ignore testing private property
568+
const mdOpts = mdApiDeploy.options;
569+
expect(mdOpts.apiOptions).to.have.property('checkOnly', true);
570+
expect(mdOpts.apiOptions).to.have.property('rollbackOnError', true);
571+
expect(mdOpts.apiOptions).to.have.property('ignoreWarnings', false);
572+
expect(mdOpts.apiOptions).to.have.property('singlePackage', true);
573+
expect(mdOpts.apiOptions).to.have.property('testLevel', 'RunLocalTests');
574+
});
575+
576+
it('should use default API options', () => {
577+
const mdApiDeploy = new MetadataApiDeploy({
578+
usernameOrConnection: 'testing',
579+
components: new ComponentSet(),
580+
});
581+
// @ts-ignore testing private property
582+
const mdOpts = mdApiDeploy.options;
583+
expect(mdOpts.apiOptions).to.have.property('rollbackOnError', true);
584+
expect(mdOpts.apiOptions).to.have.property('ignoreWarnings', false);
585+
expect(mdOpts.apiOptions).to.have.property('checkOnly', false);
586+
expect(mdOpts.apiOptions).to.have.property('singlePackage', true);
587+
});
588+
});
556589
});

0 commit comments

Comments
 (0)